Code Festival B Union Find by shinh

#!perl -nla
($a,$x,$y)=map{$b=$_;$d[$_]=$b=$@while$@=$d[$b];$b}@F;$a*$y?print$x-$y?NO:YES:$x-$y?$d[$x]=$y:0

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

download

return to the top page