#P7100. [W1] 团
[W1] 团
Description
I have an undirected weighted graph with nodes. It has many edges, and it is represented in the following way:
- There are sets. The -th set can be written as $S_i=\{(T_1,W_1),(T_2,W_2),\dots,(T_{|S_i|},W_{|S_i|})\}$.
- For any two pairs in the same set, the graph will contain an edge connecting and , with edge weight .
For every node , find the shortest path from to , i.e., a simple path from to with the minimum total edge-weight sum.
Input Format
The first line contains two positive integers .
Next, describe the sets.
The first line of the description of set contains a positive integer , which is the size of .
Then follow lines, each containing two positive integers , meaning .
Output Format
Output one line with positive integers. The -th positive integer is the length of the shortest path from to . If no path exists, output .
5 2
3
1 1
2 1
5 3
3
2 1
3 2
4 1
0 2 5 4 4
Hint
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For of the testdata, $1\le|N|\le2\cdot10^5,\sum|S_i|\le4\cdot10^5,0\le W_i\le10^9$.
Translated by ChatGPT 5
京公网安备 11011102002149号