problem
solution
codes
#include<iostream>
using namespace std;
int fa[200010];
int find(int x){return x==fa[x] ? x : fa[x]=find(fa[x]);}
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 a, b, c; cin>>a>>b>>c;
if(a == 1)fa[find(b)]=find(c);
else cout<< (find(b)==find(c)?"Y":"N")<<"
";
}
return 0;
}