luogu#P10928. 走廊泼水节
走廊泼水节
Problem Description
Given a tree with nodes, you need to add some edges to extend this tree into a complete graph, while ensuring that the unique minimum spanning tree of the graph is still this tree.
Find the minimum possible total weight of the added edges.
Note: All edge weights in the tree are integers, and all newly added edge weights must also be integers.
Input Format
The first line contains an integer , meaning there are groups of testdata.
For each group of testdata, the first line contains an integer .
The next lines each contain three integers , meaning there is an edge between node and node with length .
Output Format
For each group of testdata, output one integer, meaning the minimum total weight.
Each result occupies one line.
2
3
1 2 2
1 3 3
4
1 2 3
2 3 4
3 4 5
4
17
Hint
Constraints: , , .
Translated by ChatGPT 5