Cheapest Route — Solution & Editorial
Dijkstra with a binary heap; skip popped entries that are stale (distance already improved). Positive weights make it valid.
Complexity: O(M log N)
Watch out: Distances reach 2×1010 — use 64-bit distance values.
Dijkstra with a binary heap; skip popped entries that are stale (distance already improved). Positive weights make it valid.
Complexity: O(M log N)
Watch out: Distances reach 2×1010 — use 64-bit distance values.