#P2505. [HAOI2012] 道路
[HAOI2012] 道路
Description
Country C has cities connected by directed roads. A path is called a shortest path if and only if there does not exist another path from its start to its end whose total length is smaller. Two shortest paths are different if and only if the sequences of roads they contain are different. We need to assess the importance of each road by counting how many different shortest paths pass through that road. Now, this task is given to you.
Input Format
The first line contains two positive integers .
Each of the next lines contains three positive integers , indicating there is a road from to with length .
Output Format
Output lines. The -th line contains one number: the number of shortest paths that pass through the -th road, modulo .
4 4
1 2 5
2 3 5
3 4 5
1 4 8
2
3
2
1
Hint
Constraints
of the testdata satisfies: .
of the testdata satisfies: .
of the testdata satisfies: .
Multiple edges may exist.
Translated by ChatGPT 5
京公网安备 11011102002149号