haooo @ 2020-04-14 18:01:43
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int par[10005];
int find(int p){
if(par[p]==0){
return p;
}
par[p]=find(par[p]);
return par[p];
}
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d%d%d",&a,&b,&c);
if(a==1){
par[find(b)]=find(c);
}
else{
if(find(b)==find(c)){
cout<<"Y"<<endl;
}
else cout<<"N"<<endl;
}
}
return 0;
}
为什么会MLE啊啊啊 求助求助
by HearTheWindSing @ 2020-04-14 18:37:59
切紫花之神不会并查?
by haooo @ 2020-04-16 16:06:32
jc....
by HJY202three @ 2020-04-25 12:14:55
切紫花之神不会并查集?