Dijkstra's algorithm speedup in problem 83