AlgorithmOJ
Problem
Local Problems
All Problems
Problem Category
Status
Contest
Standard Contests
Replay Contests
Virtual Contests
Ranklist
More...
News
About
F.A.Q
Recent Contests
Coming Soon...
Login
Register
2025-07-08 01:33:46
王国的成熟度
Time Limit:
1000ms
Memory Limit:
32768KB
64-bit integer IO format:
%lld
Java class name:
Main
Prev
Submit
Status
Statistics
Next
Font Size:
Description
ACMCLUB王国有n+1座城市,标号分别是0到n,并且所有城市构成树状结构。0是国王所在的城市,相当于树状结构中的根。其他城市的成熟度定义为从0到该城市所包含的城市数(不包括0和该城市自己)。我们把最大的那个城市的成熟度作为整个王国的成熟度,现在我们想知道王国成熟度是多少。
Input
输入第一行为整数n(n<=10000),接下来有n行,每行输入一个数字,第i行表示节点i的父节点。数据保证构成一棵树。
Output
对于每组输入,输出一行,表示王国的成熟度。
Sample Input
5 3 3 0 2 0
Sample Output
2
Author
Admin
Language:
C++ (GCC 5.4.0)
C++11 (GCC 5.4.0)
C++14 (GCC 6.3.0)
C (GCC 5.4.0)
Java (OpenJDK 1.8.0)
Pascal (FPC 3.0.0)
Python2 (2.7.12)
Python3 (3.5.2)
Python3 (3.8.2)
C# (Mono 4.2.1)
Fortran
Perl
Ruby
Ada
SML
Visual C++
Visual C
CLang
CLang++
Theme:
Monokai
Solarized Light
Material
Share Code?
Yes
No
×
Login
Username:
Password:
Cookie:
Never
One Day
One Week
One Month
One Year
×
Register
Username:
Password:
Repeat Password:
Nickname:
School:
Email:
×
News Title
by