暮雪少年与树
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Background
After winning the silver medal, the young Muxue enrolled at Peking University. While happily walking on a forest path, he recalled an unsolved problem from the competition.
Problem Description
Young Muxue has a tree with vertices and a complete graph with vertices. Both the tree and the graph have edge weights, and every natural number less than appears exactly once among the edge weights of the tree. The length of an edge in the complete graph is defined as the of the edge weights along the unique simple path from to in the tree.
You are given the tree, and you need to tell Muxue the total weights of the minimum spanning tree and the maximum spanning tree of his complete graph.
Input Format
The first line contains an integer .
The next lines each contain three non-negative integers , representing an edge in the tree.
Output Format
Output one line with two integers: the total weight of the minimum spanning tree and the total weight of the maximum spanning tree.
Sample Input/Output 1
Input
5
1 2 0
1 3 1
1 4 2
1 5 3
Output
1 5
Constraints
For all test data, it is guaranteed that:, , .
【XJS-C5-Div2】XJSOI 春节大月赛 Round 3 & 勰码可达鸭合作赛 Round 1
- 状态
- 已结束
- 规则
- IOI
- 题目
- 5
- 开始于
- 2026-2-14 0:00
- 结束于
- 2026-2-17 0:00
- 持续时间
- 5 小时
- 主持人
- 参赛人数
- 4