#abc361e. E - Tree and Hamilton Path 2
E - Tree and Hamilton Path 2
Score : points
问题陈述
在AtCoder国,有个城市,编号从到,以及条道路,编号从到。
道路双向连接城市和,其长度为。任何一对城市都可以通过一些道路相互到达。
找出从某个城市出发,至少访问所有城市一次,使用道路所需的最小旅行距离。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
In the nation of AtCoder, there are cities numbered to and roads numbered to .
Road connects cities and bidirectionally, and its length is . Any pair of cities can be reached from each other by traveling through some roads.
Find the minimum travel distance required to start from a city and visit all cities at least once using the roads.
Constraints
- All input values are integers.
- Any pair of cities can be reached from each other by traveling through some roads.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
1 2 2
1 3 3
1 4 4
Sample Output 1
11
If you travel as , the total travel distance is , which is the minimum.
Note that you do not need to return to the starting city.
Sample Input 2
10
10 9 1000000000
9 8 1000000000
8 7 1000000000
7 6 1000000000
6 5 1000000000
5 4 1000000000
4 3 1000000000
3 2 1000000000
2 1 1000000000
Sample Output 2
9000000000
Beware overflow.