Why solution mentioned is making bidirectional edge?

this is my solution and why solution is complicating simple approach??

since it a tree and it will not contain cycle therefore why to make bidirctional edge???

@ssanjuchandra
bidirectional edges are used because there is nothing defined in the question about the direction, so it is advised to take the bidirectional edges. As you can see on the spoj it is written " Each line contains a pair ( u , v ) means there is an edge between node u and node v"
So just take a example like below and you will get to know what is other possibility :-
3
2 1
2 3

Although undirectional edges solution is passing on spoj, because it seems they are not taking those type of cases. But there can be these type of cases in other questions.

I hope you have understood what i am trying to say here.
Please mark the doubt as resolved if your doubt is clear now.