Code Festival B Union Find by tails

l[1<<17];a;b;main(c,d){for(gets(d);l[b]?b=l[b]:l[c]?c=l[c]:~scanf("%d%d%d",&a,&b,&c,a?puts(b-c?"NO":"YES"):b-c?l[b]=c:0););}

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

download

return to the top page