标签:int lse problem name http bsp span targe color
https://www.luogu.org/problemnew/show/P3367
1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m, f[10010], z, x, y; 4 int find(int k){ 5 if(f[k]==k)return k; 6 return f[k]=find(f[k]); 7 } 8 int main(){ 9 cin>>n>>m; 10 for(int i=1; i<=n; i++) 11 f[i]=i; 12 for(int i=1; i<=m; i++){ 13 cin>>z>>x>>y; 14 if(z==1) 15 f[find(x)]=find(y); 16 else 17 if(find(x)==find(y)) printf("Y\n"); 18 else printf("N\n"); 19 } 20 return 0; 21 }
标签:int lse problem name http bsp span targe color
原文地址:https://www.cnblogs.com/Aze-qwq/p/9337722.html