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

建议使用的浏览器:

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

5331:Simple Problem

题目描述
As we know, Rikka is poor at math. Yuta is worrying about this situation. He's given Rikka many math tasks to practice but she hasn't solved any of them. So, today he comes up with a simple problem to help her build up confidence:

Here is a tree with $m$ nodes, you can delete some of the nodes on the tree and there mustn't be any edges connecting two remained nodes. You need to maximize the number of the points remained.

Rikka thinks this task is too simple, so she comes up with a new problem:

At first there is a tree with only one node. And then each time she links a new node to the tree. After each operation, you need to tell her the maximum number of the points remained (as described above).

This problem is too difficult for Rikka to solve. Can you help her?
输入解释
There are no more than 100 testcases and there are no more than 3 testcases with $n > 10^3$.

For each testcase, the first line contains a number $n\ (1 \leq n \leq 10^5)$.

Then $n-1$ lines follow. The $i$th line contains a single number $f_i \ (0 \leq f_i <i)$, which means that after the $i$th operation there is a new node numbered $i$ and there is an edge between node $i$ and node $f_i$.
输出解释
For each operation you need to print a single line with a single number - the answer after this operation.
输入样例
4
0
0
1
输出样例
1
2
2
来自杭电HDUOJ的附加信息
Author XJZX
Recommend wange2014

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

源链接: HDU-5331

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

共提交 0

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