标签:std col turn div get == mamicode main void
#include<iostream> #include<cstdio> using namespace std; int fa[10001],z,n,m,x,y; int getfather(int w) { if(fa[w]==w) return w; fa[w]=getfather(fa[w]); return fa[w]; } void together(int a,int b) { fa[getfather(a)]=getfather(b); } int main() { cin>>n>>m; for(int i=1;i<=n;i++) { fa[i]=i; } for(int i=1;i<=m;i++) { cin>>x>>y>>z; if(x==1) { together(y,z); } if(x==2) { int yy=getfather(y); int zz=getfather(z); if(yy==zz) cout<<"Y"<<endl; else cout<<"N"<<endl; } } return 0; }
标签:std col turn div get == mamicode main void
原文地址:https://www.cnblogs.com/north-star/p/11489287.html