#P9675. [ICPC 2022 Jinan R] Shortest Path
[ICPC 2022 Jinan R] Shortest Path
题目描述
You are given an undirected weighted graph with vertices . Please output the sum of the answers to the following questions:
- The -th question ): What is the minimum length of path that starts at vertex , ends at vertex , and contains exactly edges?
For each question, if such a path does not exist, the answer is considered to be . A path may use one edge multiple times. Output the answer modulo .
输入格式
The first line contains one integer , the number of test cases.
For each test case, the first line contains three integers $n, m, x~(1\le n\le 2000, 0\le m\le 5000, 1\le x\le 10^9)$. Each of the next lines describes an edge of the graph. Edge is denoted by three integers , the labels of vertices it connects and its weight. Note that self-loops and parallel edges may exist.
It is guaranteed that the sum of over all test cases is no more than and the sum of over all test cases is no more than .
输出格式
For each test case, output one integer modulo denoting the answer.
4
3 2 10
1 2 5
2 3 4
3 0 1000000000
3 3 100
1 2 3
1 3 4
2 3 5
4 6 1000000000
1 2 244
1 2 325
1 4 927
3 3 248
2 4 834
3 4 285
125
0
15300
840659991