getting WA in CSTREET spoj. Minimum spanning tree probelm.

Problem link: http://www.spoj.com/problems/CSTREET/

my solution: http://ideone.com/1jkKLl

Please help me figure out where I did it wrong