Hi everyone.

I’ve been looking for a solution the whole day but I can’t find an algorithm to solve the following.

In most of the problems refereed to “Trees” in Codechef the inputs are N-1 lines where each line has numbers U and V representing an edge. My question is, does anyone know an algorithm to build a tree only with the set of the edges?

Note. Look that when the numbers U V are given they don’t have an special order. (1,2) does not mean that 1 is the parent of 2 or viceversa.

Thank you very much