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

建议使用的浏览器:

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

4980:A simple graph problem.

题目描述
There’s a maze with N steles. There are N-1 paths between those steles so that the maze looks like a tree. An adventure team wants to explorer all paths of the maze. They decide to air-drop some members at those steles, and then those members begin their tour to explore. It costs K dollars to drop one member. Unfortunately, there are some bandits on some paths. They will rob C dollars if a member goes through that path. No member could pass the same path twice, calculate the minimum cost to fully explore the maze.
The maze is considered fully explored if and only if all paths are explored by one of the members.
输入解释
The first line of input contains only one integer T(<=100), the number of test cases.

For each case, the first line contains 2 integers, N(<=500) and K(<=1000) as described before. The following N-1 lines describe the path. Each line has 3 integers, S, E (0<=S, E<N) and C (<=1000), which S is the start point and E is the end point.
输出解释
Each output should occupy one line. Each line should start with "Case #i: ", with i implying the case number. For each case, just output the minimum cost to explore all paths.
输入样例
2
6 2
0 1 5
0 2 1
0 3 10
0 4 5
1 5 9
6 13
0 1 2
0 2 7
0 3 9
1 4 8
1 5 7
输出样例
Case #1: 34
Case #2: 61

提示
for case#2
we need two person to fully explore the maze with minimum cost. One go though 4->1->0->2, another go though 5->1->0->3.
来自杭电HDUOJ的附加信息
Author BJTU
Recommend

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

源链接: HDU-4980

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

共提交 0

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