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

建议使用的浏览器:

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

3887:Counting Offspring

题目描述
You are given a tree, it’s root is p, and the node is numbered from 1 to n. Now define f(i) as the number of nodes whose number is less than i in all the succeeding nodes of node i. Now we need to calculate f(i) for any possible i.
输入解释
Multiple cases (no more than 10), for each case:
The first line contains two integers n (0<n<=10^5) and p, representing this tree has n nodes, its root is p.
Following n-1 lines, each line has two integers, representing an edge in this tree.
The input terminates with two zeros.
输出解释
For each test case, output n integer in one line representing f(1), f(2) … f(n), separated by a space.
输入样例
15 7
7 10
7 1
7 9
7 3
7 4
10 14
14 2
14 13
9 11
9 6
6 5
6 8
3 15
3 12
0 0
输出样例
0 0 0 0 0 1 6 0 3 1 0 0 0 2 0
来自杭电HDUOJ的附加信息
Author bnugong
Recommend lcy

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

源链接: HDU-3887

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

共提交 0

通过率 --%
时间上限 内存上限
15000/5000MS(Java/Others) 32768/32768K(Java/Others)