Comintern @ 2021-08-10 21:28:07
来看我这个30分的代码表示难过(;′⌒`)
#include<bits/stdc++.h>
using namespace std;
long long fa[200001];
int findfa(int a){
if(fa[a]==a)return a;
fa[a]=findfa(fa[a]);
return fa[a];
}
void bing(int a,int b){
if(a<b)swap(a,b);
if(findfa(a)==findfa(b))return ;
fa[b]=a;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=1;i<=m;i++){
int x,y,z;
cin>>x>>y>>z;
if(x==1){
bing(y,z);
}
if(x==2){
if(findfa(y)==findfa(z))printf("Y\n");
else printf("N\n");
}
}
return 0;
}
by Yukinoshita_Yukino @ 2021-08-10 21:35:40
你大佬不屑
by MeowScore @ 2021-08-10 21:36:54
屑标题
by Comintern @ 2021-08-10 21:38:35
@落日斜阳 您这么一讲,我就懂了,刚才我还在纠结为什么要找两次父亲
by Comintern @ 2021-08-10 21:40:02
@Wu_while 谢啦!!☆⌒(*^-゜)v
by _Sparkle @ 2021-08-10 21:44:25
by Lazy_Labs @ 2021-08-10 21:48:25
@蒟蒻小白orz 给你加一个橙名的粉丝咋样\kk
by Comintern @ 2021-08-10 21:55:47
@a929666 谢谢lzy巨佬(^_^)