2

ykj70 2022-11-27 16:06:56 0
#include<bits/stdc++.h>
using namespace std;
int deep[1000010]; 
int main()
{
	int n,a,b,maxn=0;
	cin>>n;
	deep[1]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		if(a!=0)
		{
			deep[a]=deep[i]+1;
			maxn=max(maxn,deep[a]);
		}
		if(b!=0)
		{
			deep[b]=deep[i]+1;	
			maxn=max(maxn,deep[b]);
		}
	}
	cout<<maxn;
	return 0;
}
{{ vote && vote.total.up }}