当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6074:Phone Call

题目描述
There are $n$ houses in Bytetown, labeled by $1,2,...,n$. In each house, there is a person living here. Little Q lives in house $1$. There are $n-1$ bidirectional streets connecting these houses, forming a tree structure. In this problem, $S(u,v)$ denotes the house set containing all the houses on the shortest path from house $u$ to house $v$.

The Bytetown's phone line network consists of $m$ different lines. The $i$-th line can be expressed as $5$ integers $a_i,b_i,c_i,d_i,w_i$, which means for every two different houses $u$ and $v$ from set $S(a_i,b_i)\cup S(c_i,d_i)$, $u$ and $v$ can have a phone call costing $w_i$ 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.
输入解释
The first line of the input contains an integer $T(1\leq T\leq15)$, denoting the number of test cases.

In each test case, there are $2$ integers $n,m(1\leq n,m\leq 100000)$ in the first line, denoting the number of houses and phone lines.

For the next $n-1$ lines, each line contains two integers $u$ and $v$, denoting a bidirectional edge between node $u$ and $v$.

For the next $m$ lines, each line contains $5$ 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.
输出解释
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.
输入样例
1
5 2
1 2
1 3
2 4
2 5
1 3 2 4 100
2 2 4 2 10
输出样例
4 210
提示
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.
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6074

最后修改于 2020-10-25T23:28:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/524288K(Java/Others)