Minimum Spanning Tree by nn

for(g=[],j=-99;j++<122;g[/\d+/(l=readline())]=l)if(s=g[j])for([a,b]=s.split(S=' '),q=g[a]+S,print('FT'[p=+!q.match(S+b+S)],s),q+=g[b]+S+s;c=/\w+/g(p&&q);)g[c]=q

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

download

return to the top page