### LunaticPriest's blog

By LunaticPriest, history, 6 weeks ago, ,

Hi, the mightly Codeforces community! I'm having some problems with an easy shortest path question. I'm trying to solve Jzzhu and Cities and my code gets a TLE at 45th test case :( I'm basically using Dijkstra's Algo, only with the optimization that I store the information whether a node is reached by a railroad or a normal one. Here is the code. Thanks in advance for all your optimization advice, I'll do my best!

• +35

 » 6 weeks ago, # |   +20 Because in a priority queue based Dijkstra there is a twist itself.You either need to pop the nodes directly from the priority queue (which is rarely used) or you do the lazy-deletion hack where you pop the top of the queue if it is no longer valid.Check out the difference between 66995018 and 66995014.The Dijkstra without the hack or the popping does not have the complexity of $O(E \cdot \log V)$
•  » » 6 weeks ago, # ^ |   +8 Thank you for the wonderful explanation and all the effort! Now I understood my mistake and will never repeat!!