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

建议使用的浏览器:

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

5770:Treasure

题目描述
?? has got a treasure map,the treasure map consists of N nodes,there are N-1 bidirectional roads, Each of them connects a pair of nodes,the N nodes are all connected by the N-1 bidirectional roads.?? can travel through the roads.
There are M treasures in some node. Each treasure has a value, treasures are put into boxs,each treasure corresponds to a box and each box corresponds to a key which is also in some node. Now ?? wants to plan a simple path, the path’s start point is node A,and the path’s destination is node B,?? will go from node A to node B. When ?? goes through a node(including node A and node B), he must first collects all keys, and then must open the boxes he can open in this node. The keys he got never disappear during the travel. Now ?? wants to know the maximum value he could get if he plan a best path.Can you help him?

输入解释
The first line of the input gives the number of case T,T test cases follow.
Each case first line contains two integer n,m(n,m<=100000)indicating the number of nodes and the number of treasures.
Next n-1 lines each line contains two numbers ui and vi(1<=ui,vi<=n) indicates that there’s one road connecting node ui node vi.
Next m lines each line contains three number ui,vi,wi(1<=ui,vi<=n,-1000<=wi<=1000) indicates the position of ith-box’s key and the position of ith-box, and the value of treasure in the ith-box.

T<=30
The sum of n in all the test cases is no more than 600000
The sum of m in all the test cases is no more than 600000

输出解释
For each that case output”Case #x: y”,where x is the test case number(starting from 1),and y is the answer you get for that case.
输入样例
2
4 2
1 2
2 3
3 4
1 1 100
2 4 -5
4 3
1 2
1 3
1 4
2 1 1
1 3 2
1 3 5
输出样例
Case #1: 100
Case #2: 8
来自杭电HDUOJ的附加信息
Author FZU
Recommend wange2014

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

源链接: HDU-5770

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

共提交 0

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