Code Festival B Union Find by orisano

p[' ~~'],r,a;R(x){a=p[x]?R(p[x]),p[x]=a:x;}main(b,c){for(gets(c);~scanf("%d%d%d",&r,&b,&c);!r?b-a?p[b]=a:0:puts(b-a?"NO":"YES"))R(b),b=a,R(c);}

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

download

return to the top page