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

建议使用的浏览器:

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

3274:City Planning

题目描述
Recently Bob received a job. It’s to reform the city’s transport system. Since the city has so many villages, and the transportation network is so large that the government want to reduce the roads number. The government has just choose some of them, your duty is to build a transportation network between them to make them link with each other directly or indirectly. Meanwhile you should use the least money. You may suppose that the initial transportation network makes up a tree.
输入解释
There are several test cases.
Each case starts with two integers n and m in a line. n stands for the number of all villages, m stands for the number of villages the government has chosen.( 0 < n < 1000, 0 < m <= n)
Then follow m integers in a line which means the chosen villages.
Then n - 1 lines follow, each line contains three integers a, b, c, indicating that between a and b there is a road available which costs c. (1 <= a, b <= n, a! = b, c <= 2000)
输出解释
For each test case, output the least money you need to use in a line.
输入样例
6 3
2 3 4
1 2 3
1 3 1
3 6 4
2 5 4
2 4 2
输出样例
6
来自杭电HDUOJ的附加信息
Author dandelion
Recommend chenheng

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

源链接: HDU-3274

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

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)