Weighted shortest paths: Given a directed graph with non-negative weighted edges, return the shortest distance from source to every node. Use null for unreachable nodes.
Input: A JSON object { "n": number, "edges": [number,number,number][], "source": number }.
Output: A JSON array of numbers or null values with length n.
Constraints:
- 0 <= n <= 100000
- Edge weights are non-negative safe integers
- Nodes are numbered from 0 to n-1
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: HARD. Variant: 15. Balance correctness, maintainability, and clear review-ready code.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked hard difficulty.
The signed-in workspace provides the tools required