#p866. 例题8.4.2 求树的深度和子树大小

例题8.4.2 求树的深度和子树大小

题目描述

给定一棵nn个点的无权树,问树中每个节点的深度和每个子树的大小?

(以1号点为根节且深度为0)

输入格式

第1行:nn

第2~n行:每行两个数x,yx,y,表示x,yx,y之间有一条边。

输出格式

n行,每行输出格式为:#节点编号 deep:深度 count:子树节点数(详见样例)

样例数据

input


7

1 2

2 3

1 4

3 5

1 6

3 7

output


#1 deep:0 count:7

#2 deep:1 count:4

#3 deep:2 count:3

#4 deep:1 count:1

#5 deep:3 count:1

#6 deep:1 count:1

#7 deep:3 count:1

数据规模与约定

15% n<=10;

40% n<=1000;

100% n<=100000;

(数据很乱。。。嗯。。。没错。。。)

make data by 俞越 & 杨久知

时间限制:1s1 \text {s}

空间限制:256MB256 \text {MB}