#include<iostream>
using namespace std;
const int M=100010;
int n;
struct node {
int left,right;
} t[M];
void build() {
for(int i=1; i<=n; i++)
scanf("%d%d",&t[i].left,&t[i].right);
}
int dfs(int x) {
if(!x) return 0;
else return max(dfs(t[x].left),dfs(t[x].right))+1;
}
int main() {
cin>>n;
build();
cout<<dfs(1)<<endl;
return 0;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交