Lisbeth_Rivaille @ 2018-08-28 18:27:47
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,fa[1001000],x,y,z;
int find(int now){
if(fa[now]==now)return now;
return fa[now]=find(fa[now]);
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=1;i<=m;i++){
scanf("%d%d%d",&x,&y,&z);
if(x==1)fa[fa[y]]=z;
else if(find(z)==find(y))printf("Y\n");
else printf("N\n");
}
return 0;
}
1,4,5AC,其他RE,看不出是为虾米,求助qwq
by Lolierl @ 2018-08-28 18:52:25
@待捕捉蒟蒻QvvQ
fa[fa[y]]=z;
改成
fa[find(y)] = find(z);
by LCuter @ 2018-08-28 19:04:51
@待捕捉蒟蒻QvvQ %%%小号都蓝了
by Lisbeth_Rivaille @ 2018-08-28 19:31:12
已解决,谢谢各位dalao