Can anybody explain me this code of tourist from yesterday's contest?

Revision en2, by Rock2000, 2020-07-05 14:58:59

Problem link

Tourist Code

What I do not understand is how after finding array b we get the correct answer.
Thanks in advance.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Rock2000 2020-07-05 14:58:59 86 Tiny change: ' b we get correct a' -> ' b we get the correct a'
en1 English Rock2000 2020-07-05 14:57:14 1062 Initial revision (published)