Problem "Returning Home" (1422D), TLE on Test 5

Revision en1, by ynnuface, 2020-10-10 12:30:06

Basically for every node I calculate the 4 closest nodes in all four directions, so the number of edges should be at most 4*M, right?

After that I run Dijkstra but for some reason I get TLE on test 5, I spent a lot of hours trying to see why but with no success, that's why I'm asking for some help, I just don't know what's wrong with my implementation.

Code link: https://codeforces.com/contest/1422/submission/95066276

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ynnuface 2020-10-10 13:07:19 407
en1 English ynnuface 2020-10-10 12:30:06 474 Initial revision (published)