#Q69. 「一本通 3.1 练习 2」构造完全图
「一本通 3.1 练习 2」构造完全图
Description
For a complete graph , if there is exactly one minimum spanning tree , then the complete graph is said to be extended by the tree .
Given a tree , find the complete graph with the smallest sum of edge weights that can be extended by .
Input Format
The first line contains , the number of vertices in the tree ;
The next lines each contain three integers ; describing an edge with weight ;
It is guaranteed that the input data forms a tree.
Output Format
Output only one number, representing the smallest sum of edge weights for the complete graph .
Sample 1
Add to achieve this.
4
1 2 1
1 3 1
1 4 2
12
Data Range and Hints
For of the data, ;
For of the data, ;
For of the data, .