#P7473. [2017年杭电多校]Phone Call
[2017年杭电多校]Phone Call
Phone Call
Problem Description
There are houses in Bytetown, labeled by . In each house, there is a person living here. Little Q lives in house . There are bidirectional streets connecting these houses, forming a tree structure. In this problem, denotes the house set containing all the houses on the shortest path from house to house . The Bytetown's phone line network consists of different lines. The -th line can be expressed as integers , which means for every two different houses and from set , and can have a phone call costing dollars. Picture from Wikimedia Commons Little Q is now planning to hold a big party in his house, so he wants to make as many as possible people known. Everyone known the message can make several phone calls to others to spread the message, but nobody can leave his house. Please write a program to figure out the maximum number of people that can join the party and the minimum total cost to reach that maximum number. Little Q should be counted in the answer.
Input
The first line of the input contains an integer , denoting the number of test cases. In each test case, there are integers in the first line, denoting the number of houses and phone lines. For the next lines, each line contains two integers and , denoting a bidirectional edge between node and . For the next lines, each line contains integers $a_i,b_i,c_i,d_i,w_i(1\leq a_i,b_i,c_i,d_i\leq n,1\leq w_i\leq 10^9)$, denoting a phone line.
Output
For each test case, print a single line containing two integers, denoting the maximum number of people that can join the party and the minimum total cost to reach that maximum number.
Sample Input
1
5 2
1 2
1 3
2 4
2 5
1 3 2 4 100
2 2 4 2 10
Sample Output
4 210
Hint
Step 1 : 1 make a phone call to 2 using line 1, the cost is 100. Step 2 : 1 make a phone call to 3 using line 1, the cost is 100. Step 3 : 2 make a phone call to 4 using line 2, the cost is 10.
Source
2017 Multi-University Training Contest - Team 4