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

建议使用的浏览器:

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

3585:Accumulation Degree

题目描述

Trees are an important component of the natural landscape because of their prevention of erosion and the provision of a specific ather-sheltered ecosystem in and under their foliage. Trees have also been found to play an important role in producing oxygen and reducing carbon dioxide in the atmosphere, as well as moderating ground temperatures. They are also significant elements in landscaping and agriculture, both for their aesthetic appeal and their orchard crops (such as apples). Wood from trees is a common building material.

Trees also play an intimate role in many of the world's mythologies. Many scholars are interested in finding peculiar properties about trees, such as the center of a tree, tree counting, tree coloring. A(x) is one of such properties.

A(x) (accumulation degree of node x) is defined as follows:

  1. Each edge of the tree has an positive capacity.
  2. The nodes with degree of one in the tree are named terminals.
  3. The flow of each edge can't exceed its capacity.
  4. A(x) is the maximal flow that node x can flow to other terminal nodes.

Since it may be hard to understand the definition, an example is showed below:


A(1)=11+5+8=24
Details:1->211
 1->4->35
 1->4->58(since 1->4 has capacity of 13)
A(2)=5+6=11
Details:2->1->4->35
 2->1->4->56
A(3)=5
Details: 3->4->55
A(4)=11+5+10=26
Details:4->1->211
 4->35
 4->510
A(5)=10
Details:5->4->1->210

The accumulation degree of a tree is the maximal accumulation degree among its nodes. Here your task is to find the accumulation degree of the given trees.

输入解释

The first line of the input is an integer T which indicates the number of test cases. The first line of each test case is a positive integer n. Each of the following n - 1 lines contains three integers x, y, z separated by spaces, representing there is an edge between node x and node y, and the capacity of the edge is z. Nodes are numbered from 1 to n.
All the elements are nonnegative integers no more than 200000. You may assume that the test data are all tree metrics.

输出解释

For each test case, output the result on a single line.
 

输入样例
1
5
1 2 11
1 4 13
3 4 5
4 5 10
输出样例
26

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3585

最后修改于 2020-10-29T07:05:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536