| April Fools Day Contest 2026 |
|---|
| Finished |
You are given a graph of $$$n$$$ nodes and $$$m$$$ undirected edges. Find the shortest path from node $$$1$$$ to each node with Dikjstra's algorithm.
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(2 \leq n \leq 100, 0 \leq m \leq \frac{n(n-1)}{2})$$$.
The following $$$m$$$ lines contain $$$3$$$ integers each: $$$u$$$, $$$v$$$, and $$$w$$$, denoting an undirected edge from $$$u$$$ to $$$v$$$ with weight $$$w$$$ $$$(1 \leq u, v \leq n, 0 \leq w \leq 10^5)$$$.
Output the shortest path from node $$$1$$$ to each node $$$2, \dots, n$$$. If a node is not reachable from node $$$1$$$, output $$$-1$$$.
2 11 2 1
1
5 51 2 71 3 41 4 92 3 63 4 2
7 4 6 -1
5 61 5 22 1 63 4 24 2 95 3 72 3 4
6 9 12 2
| Name |
|---|


