Code Festival B Union Find by catupper

u['zzz'],p;r(x){u[x]=u[x]-x?r(u[x]):x;}main(q,a,b,c,n){for(scanf("%d%d",&n,&q);u[n]=n--;);for(;q--;!a?u[b]=c:puts(b-c?"NO":"YES"))scanf("%d%d%d",&a,&b,&c),b=r(b),c=r(c);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page