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

建议使用的浏览器:

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

4684:The Budget of Traveler

题目描述
There is a country consisting of n cities. A traveler living in the city with number 1 loves travelling very much. He has made
n-1 travel plans, each plan has a unique destination(except city 1). After a travel, he will go back home. On the way back home,
he will buy gifts for all his friends living in the cities(including the starting city and ending city) he will pass. For some
strange reasons, each city sells only one kind gift. Besides, packing the gifts need some extra cost.
Maybe you are still confused of the description, the following is the details
1. Note that the cities form a connected, undirected and a cyclic graph(in another word the cities form a tree).
2. When he goes back home after a travel, he will always choose the shortest route.
3. The n-1 plans are independent, that means, he will always prepare gifts for his friends ont the route no matter whether he has visited them before.
4. The gifts must be packed, and you must pack them in the city where you buy them.
5. The packing cost is no matter with the number of gifts. That is, packing two gifts cost the same money with packing one.
输入解释
The first line of the input contains an integer T( T<= 10 ), indicating the number of test cases.
For each test case, the first line contains only one integers n, indicating the number of cities.
The next n lines, each line contains three integers fi, pi, ri, where fi is the number of his friend living in city i, pi is the price of each gift in city i, ri is the packing cost in the city i.
The next of n-1 lines, each line contains two integers ui and vi, indicating that the traveler can go to vi from ui or go to ui from vi.
You can assume 1<=n<=4*105, 1<=fi<=104, 1<=pi,ri<=105, 1<=ui,vi<=n

输出解释
For every test case,output one line,"Case #k: ans",where k is the case number,counting from 1, ans is the minimum total cost.
输入样例
1
3
1 10000 10000
1 1 20
1 100 1
1 2
1 3
输出样例
Case #1: 223
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

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

源链接: HDU-4684

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

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 131072/131072K(Java/Others)