Dijkstra?
HardRating 1900CodeforcesShortest Paths & Topological Sort
Approach hintTry it first, then revealHide
Standard Dijkstra from vertex 1 with a parent array to rebuild the route from n backwards. Use 64-bit distances and skip stale heap entries to stay within the time limit.