求助
查看原帖
求助
542905
WannaYellow楼主2021/9/24 21:05

#2 wa了一个点emmm

#include<stdio.h>
const int MAXn=1e6+20;
int n,dep[MAXn],maxx;
int main(){
	scanf("%d",&n);
	dep[0]=0;
	dep[1]=1;
	for(int i=1;i<=n;i++){
		int tmp1,tmp2;
		scanf("%d%d",&tmp1,&tmp2);
		if(tmp1)dep[tmp1]=dep[i]+1;
		if(tmp2)dep[tmp2]=dep[i]+1;
		if(tmp1||tmp2)maxx=dep[tmp1]>dep[tmp2]?(dep[tmp1]>maxx?dep[tmp1]:maxx):(dep[tmp2]>maxx?dep[tmp2]:maxx);
	}
	printf("%d",maxx);
	return 0;
}
2021/9/24 21:05
加载中...