Submission #1755140


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
vector<int>e[N],o[N];;
int fa[N],n;
int gao(int x){
	if(!e[x].size())return 0;
	re(i,0,e[x].size())o[x].pb(gao(e[x][i]));
	sort(o[x].begin(),o[x].end());reverse(o[x].begin(),o[x].end());
	int res=0;
	re(i,0,o[x].size())gmax(res,o[x][i]+i+1);
	return res;
}
int main(){
	read(n);rep(i,2,n)read(fa[i]),e[fa[i]].pb(i);
	cout<<gao(1);
}

Submission Info

Submission Time
Task B - Tournament
User xjt
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2238 Byte
Status AC
Exec Time 45 ms
Memory 63488 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 3
AC × 53
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 41 ms 52608 KB
02.txt AC 40 ms 52608 KB
03.txt AC 40 ms 52608 KB
04.txt AC 41 ms 52608 KB
05.txt AC 40 ms 52608 KB
06.txt AC 40 ms 52608 KB
07.txt AC 40 ms 52608 KB
08.txt AC 40 ms 52608 KB
09.txt AC 40 ms 52608 KB
10.txt AC 40 ms 52608 KB
11.txt AC 38 ms 63488 KB
12.txt AC 45 ms 59264 KB
13.txt AC 37 ms 57728 KB
14.txt AC 36 ms 56192 KB
15.txt AC 36 ms 55168 KB
16.txt AC 36 ms 54400 KB
17.txt AC 36 ms 53888 KB
18.txt AC 37 ms 53504 KB
19.txt AC 39 ms 53376 KB
20.txt AC 39 ms 53376 KB
21.txt AC 21 ms 50552 KB
22.txt AC 21 ms 50340 KB
23.txt AC 21 ms 50420 KB
24.txt AC 21 ms 50304 KB
25.txt AC 21 ms 50304 KB
26.txt AC 22 ms 50304 KB
27.txt AC 22 ms 50432 KB
28.txt AC 22 ms 50432 KB
29.txt AC 23 ms 50432 KB
30.txt AC 24 ms 50432 KB
31.txt AC 33 ms 52480 KB
32.txt AC 31 ms 51456 KB
33.txt AC 29 ms 50944 KB
34.txt AC 29 ms 50944 KB
35.txt AC 28 ms 51072 KB
36.txt AC 25 ms 50304 KB
37.txt AC 24 ms 50304 KB
38.txt AC 23 ms 50432 KB
39.txt AC 22 ms 50432 KB
40.txt AC 21 ms 50176 KB
41.txt AC 16 ms 49024 KB
42.txt AC 16 ms 49024 KB
43.txt AC 16 ms 49024 KB
44.txt AC 16 ms 49024 KB
45.txt AC 16 ms 49024 KB
46.txt AC 16 ms 49024 KB
47.txt AC 16 ms 49024 KB
48.txt AC 16 ms 49024 KB
49.txt AC 16 ms 49024 KB
50.txt AC 16 ms 49024 KB
s1.txt AC 17 ms 49024 KB
s2.txt AC 16 ms 49024 KB
s3.txt AC 17 ms 49024 KB