const int maxn = ; int fa[maxn]; int fi(int x) { return fa[x]==x?x:fa[x]=fi(fa[x]); } void union(int x,int y) { int fx = fi(x),fy = fi(y); if(fx != fy) fa[fx] = fy; } bool check(int x,int y) { int fx = fi(x),fy = fi(y); if(fx == fy) return true; return false; }