链接:https://ac.nowcoder.com/acm/contest/1109/H
来源:牛客网
题目描述
In ICPCCamp there were n towns conveniently numbered with 1,2,…,n1, 2, \dots, n1,2,…,n
connected with (n - 1) roads.
The i-th road connecting towns aia_iai and bib_ibi has length cic_ici.
It is guaranteed that any two cities reach each other using only roads.
Bobo would like to build (n - 1) highways so that any two towns reach each using *only highways*.
Building a highway between towns x and y costs him δ(x,y)\delta(x, y)δ(x,y) cents,
where δ(x,y)\delta(x, y)δ(x,y) is the length of the shortest path between towns x and y using roads.
As Bobo is rich, he would like to find the most expensive way to build the (n - 1) highways.
输入描述:
The input contains zero or more test cases and is terminated by end-of-file. For each test case:
The first line contains an integer n.
The i-th of the following (n - 1) lines contains three integers aia_iai, bib_ibi and cic_ici.
* 1≤n≤1051 \leq n \leq 10^51≤n≤105
* 1≤ai,bi≤n1 \leq a_i, b_i \leq n1≤ai,bi≤n
* 1≤ci≤1081 \leq c_i \leq 10^81≤ci≤108
* The number of test cases does not exceed 10.