Nodes from the Root

查看题解 查看答案
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb

请先登录再刷题,不会做的题目右上可以查看题解和答案~

输入输出格式
输入描述:
The first line is an interger T, indicating the number of test cases.
Then in each case:
The first line contains one integer N (N ≤ 2e4), representing the number of nodes in the tree.
The second line contains one integer Y (0 ≤ Y ≤ N), representing the maximum number of nodes allowed to be reachable from the root. 
Each of the following N-1 lines contains three integers U, V (0 ≤ U, V < N), W(0 ≤ W ≤ 1e7), representing that the edge between node U and node V has a weight W. The integers are separated by a space.
The total sum of N in all cases is less than 1e5.
输出描述:
T lines and each line contains an integer, representing the minimum threshold X (X≥0).
Sample Input
输入输出样例
输入样例#:
2
3 2
0 1 2
0 2 3
6 3
0 1 8
0 2 3
1 3 2
1 4 5
2 5 6
输出样例#:
复制
3
4
题目来源
南京大学2019年机试题
重置

提交代码后在此处可查看状态