#P2126. Mzc家中的男家丁
Mzc家中的男家丁
Description
mzc is very rich (just kidding). He has male servants. Now mzc wants to gather them all together (for reasons unknown). Given the communication times between mzc and the male servants, please compute the total time needed to call each of them (counting repeated uses). It is guaranteed that everyone can be called.
Input Format
The first line contains a number , indicating there are male servants.
The second line contains a number , indicating there are communication routes.
Then follow lines, each with three numbers , meaning that the time needed for communication between the -th male servant (or mzc) and the -th male servant (or mzc) is (bidirectional). Here, or denotes mzc.
Output Format
One line with a single number , representing the total time required to call each of them.
5
12
0 2 15
2 3 20
3 5 13
1 3 29
0 1 30
2 4 21
0 3 23
5 1 48
0 4 17
0 5 27
1 2 43
2 5 41
94
Hint
Constraints: , .
Translated by ChatGPT 5
京公网安备 11011102002149号