You have a directed graph with N nodes and M edges. Edge weights are positive. Find the shortest distance starting at node to every other node.
Constraints: , M ≤ .
This is the textbook Dijkstra problem. No tricks, standard implementation. Use a priority queue with (distance, node) pairs. Initialize dist[1] = 0 and all others to infinity. Process nodes in order of increasing distance and relax outgoing edges.