#P5866. [SEERC 2018] Space Station
[SEERC 2018] Space Station
Description
Jones has achieved his dream: he joined a mission to the International Space Station (ISS). He received his first task: to check whether the electronic equipment on the space station is working properly.
The ISS is divided into modules, numbered from to . Jones found that, to improve efficiency, the station was designed so that between any two modules there exists exactly one simple path. During a solar flare event, the bidirectional corridor connecting two modules can easily be affected by radiation. Checking the condition of a corridor requires time. Jones needs to find the fastest route that starts from module , passes through every corridor at least once, and returns to module .
Besides moving through the corridors between modules, Jones can also put on a spacesuit, leave the station, and move directly from one module to any other module from the outside, but he can do this at most times. Jones assumes each such move takes a fixed time .
Input Format
The first line contains an integer , which denotes the number of test cases.
For each test case, the first line contains three integers . The next lines each contain three integers $A, B, C \ (1 \leq A \leq B \leq N; 0 \leq C,K \leq 10^6)$, meaning there is a corridor between modules and , and checking it takes time.
Output Format
For each testdata, output one line containing the answer.
2
5 2 4
1 2 2
2 3 2
1 4 2
4 5 2
7 2 0
1 2 1
1 3 5
2 4 10
2 5 1
5 6 10
5 7 5
12
33
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号