#P2832. 行路难【疑似 std 复杂度有误】

行路难【疑似 std 复杂度有误】

Description

There are nn mountains in the mountainous area. There are mm narrow mountain paths between the mountains. Each path connects two mountains, is one-way, and costs Xiao X a certain amount of time.

Xiao X is currently at mountain 11. His goal is mountain nn, because there is a train station there.

However, Xiao X’s stamina is limited. Each time he traverses a narrow mountain path, he becomes more tired, causing the time to traverse any narrow mountain path to increase by 11.

Input Format

The first line contains two integers, n,mn, m.

From line 22 to line m+1m+1, each line contains 33 integers A,B,CA, B, C, indicating that there is a narrow mountain path from AA to BB that allows Xiao X to move from AA to BB with a time cost of CC.

Output Format

The first line contains an integer TT, the shortest time Xiao X needs.

The second line contains a sequence of integers separated by spaces, representing Xiao X’s route. For example, [1, 4, 2, 5] means Xiao X starts from mountain 1, moves to mountain 4, then to mountain 2, and finally to mountain 5.

5 8
2 4 2
5 2 1
1 2 1
4 3 2
1 3 3
4 5 2
1 5 8
3 5 3

7
1 3 5 

Hint

Constraints

For all testdata, n104n \le 10^4, m2×105m \le 2 \times 10^5.

The testdata guarantees that the shortest path is unique.

Translated by ChatGPT 5