Help with FBH round 2 problem C

Revision en1, by sore_loser, 2016-01-24 21:22:32

I need some help with this problem

Snakes and Ladders

Actually, I think I have got quite a hold of it. What I can't get my head around is as there may be n(n-1)/2 possible pairs at the max, how can I take all these possible pairs in less than O(N^2) time? The constraints clearly mean that O(N^2) won't do. Or is there some way to bypass this calculation? (which I am quite sure there isn't)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sore_loser 2016-01-24 21:22:32 497 Initial revision (published)