EmiliaQAQ @ 2018-11-06 20:51:49
为什么全是RE呀...
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,z,x,y,f[10001];
int find(int p)
{
if(p==f[p])return p;
else f[p]=find(f[p]);
}
int main()
{
cin>>n>>m;
int i;
for(i=1;i<=n;i++)
{
f[i]=i;
}
for(i=1;i<=m;i++)
{
cin>>z>>x>>y;
if(z==1)
{
f[find(x)]=find(y);
}
if(z==2)
{
if(find(x)==find(y))
cout<<"Y"<<endl;
else
cout<<"N"<<endl;
}
}
return 0;
}
by EmiliaQAQ @ 2018-11-06 21:01:53
@cxccxc 我知道了。。。谢谢