@[A_Dark_Horcrux](/user/54372) 这是窝的代码qwq
```cpp
#include <iostream>
#include<cstdio>
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
struct tree{
int l,r,now;
int size;
}a[1000005];
inline int get_size(int now){
if(now==-1) return 0;
return a[now].size=get_size(a[now].l)+get_size(a[now].r)+1;
}
inline bool check(int l,int r){
if(l==-1&&r==-1) return 1;
if((l==-1&&r!=-1)||(l!=-1&&r==-1)) return 0;
if(a[l].now!=a[r].now) return 0;
return check(a[l].l,a[r].r)&&check(a[r].l,a[l].r);
}
int n;
int ans;
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].now;
for(int i=1;i<=n;i++){
cin>>a[i].l>>a[i].r;
}
get_size(1);
for(int i=1;i<=n;i++){
if(check(a[i].l,a[i].r)){
ans=max(ans,a[i].size);
}
}
cout<<ans;
return 0;
}
```
by Amor_Hucsy @ 2019-11-13 20:22:13
@[Amor_Hucsy](/user/204365) 憋发代码,康康窝的QAQ
还有开O3算什么QAQ
by A_Đark_Horcrux @ 2019-11-13 20:25:17
@[A_Dark_Horcrux](/user/54372) 能下载数据让窝康康嘛QAQ
by Amor_Hucsy @ 2019-11-13 20:31:11
@[Amor_Hucsy](/user/204365) 数据:
```cpp
10
5 7 2 3 4 4 7 2 3 8
2 7
3 -1
4 -1
5 -1
-1 -1
-1 10
-1 8
-1 9
-1 6
-1 -1
```
by A_Đark_Horcrux @ 2019-11-13 20:53:40
窝的代码输出0 QAQ
by A_Đark_Horcrux @ 2019-11-13 20:54:19
@[A_Dark_Horcrux](/user/54372) 只要把ans的初值赋成1就可以了,因为答案最小为1 QAQ
by Amor_Hucsy @ 2019-11-13 21:02:42
@[Amor_Hucsy](/user/204365) 谢谢qwq!
by A_Đark_Horcrux @ 2019-11-13 21:27:00