Graph Theory37 sections · 1633 units
Open in Course

CSES 1671 Shortest Routes I - Problem Statement

(CSES - Dijkstra)

You have a directed graph with N nodes and M edges. Edge weights are positive. Find the shortest distance starting at node 11 to every other node.

Constraints: N105N \leq 10^5, M ≤ 2×1052 \times 10^5.

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.