Блог пользователя Byncuco

Автор Byncuco, история, 5 лет назад, По-английски

I tried to solve a classic probjem by using dijkstra with set, but got TLE.

I could not find out the reason why. Here is my code: Submission 65475444

Can you suggest any reasons? Thank you!

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
Rev. 3   Проголосовать: нравится +1 Проголосовать: не нравится

I just tinkered your solution a little bit and the reason I think you are getting TLE may be due to accessing pair elements more than once I just stored them in variables. For your curiosity, I made the same mistake xd and also you can speed this up using priority queue more here.

Modified Code

cheers :)