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

建议使用的浏览器:

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

5342:Dynamic Cactus

题目描述
Calcuate the longest simple path of a cactus which supports adding nodes and circles.
输入解释
First line contains a single integer $Cases \leq 5$ which denotes the number of test cases.

For each case , first line contains a single integer $T$ which denotes the number of operations.

Note nodes number with 1.Firstly,we only have one node numbered 1.

For each operation, there are two positive integer $x$ and $g$,which denote the linked node and the number of adding nodes.

We let p donates the number of nodes before adding.

If g=1 , we add a node which links p+1 .

If g>1 , we add a circle p+1,p+2,...,p+g ,p+1 and p+g link with x ,p+i links with p+i+1 $(1 \leq i < g)$.

The number of added nodes for each case not exceeding $10^{5}$.
输出解释
For each case, output the answer after operating in a single line.
输入样例
2
2
1 1
1 1
2
1 1
1 3
输出样例
1
2
1
4

提示
A simple path is a path in a graph which does not have repeating vertices.
The cactus is a graph which each edge belong to at most one simple circle.
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5342

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/524288K(Java/Others)