【模板】单源最短路径(标准版)
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Background
On July 19, 2018, a student used a well-known algorithm very skillfully to find shortest paths in the problem NOI Day 1 T1 Return Trip.
Then what?
;
;
In the end, because of this, he failed to make a contract with his ideal university.
Little F sincerely hopes that everyone will not make the same mistake again.
Problem Description
Given a directed graph with nodes and directed edges with non-negative weights, please compute the distance from to every node.
The testdata guarantees that you can reach every node starting from .
Input Format
The first line contains three positive integers . Starting from the second line, there are lines. Each line contains three non-negative integers , meaning there is a directed edge from to with weight .
Output Format
Output one line with space-separated non-negative integers, representing the distance from to each node.
4 6 1
1 2 2
2 3 2
2 4 1
1 3 5
3 4 3
1 4 4
0 2 4 3
Hint
For the sample explanation, please refer to Template Problem with Random Data.
Constraints:
;
;
;
;
,
。
The testdata of this problem may continue to be updated, but it will not be rejudged. Please be informed.
2018.09.04 Data update from @zzq.
Translated by ChatGPT 5
入门7 最短路
- Status
- Done
- Rule
- IOI
- Problem
- 6
- Start at
- 2026-11-15 22:00
- End at
- 2026-11-22 22:00
- Duration
- 168 hour(s)
- Host
- Partic.
- 36