yzkadbq_qwq @ 2022-06-11 10:23:19
stO帮我调代码的人Orz
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,fa[100001];
int find(int k){
if(fa[k]==k)return k;
return fa[k]=find(fa[k]);
}
signed main(){
cin>>n>>m;
for(int i=1;i<=n;i++)
fa[i]=i;
for(int i=1;i<=m;i++){
int opr;
cin>>opr;
if(opr==1){
int x,y;
cin>>x>>y;
fa[find(x)]=find(y);
}else{
int x,y;
if(find(x)==find(y)){
cout<<"Y\n";
}else{
cout<<"N\n";
}
}
}
return 0;
}
stO帮我调代码的人Orz
by shyr @ 2022-06-11 10:26:48
查询操作有输入吗。。。
by shyr @ 2022-06-11 10:26:55
@Arthur_zhang
by yzkadbq_qwq @ 2022-06-11 10:28:47
@Respons_ 谢谢