giving WA for [this] problem? : http://ideone.com/OqSHFi : http://www.codechef.com/problems/GALACTIK
 giving WA for [this] problem? : http://ideone.com/OqSHFi : http://www.codechef.com/problems/GALACTIK
There are two bugs in your program
The code does not take into consideration the case when all the nodes are connected by the bidirectional spaceway itself, in that case the cost required for the tournament will be zero which in your case is printing garbage value.
Secondly, your code is too slow, use scanf and printf for fast i/o and also there is no need of stl
as you just need to keep a count of the nodes used for making the teleports.
Hope this helps.
I tried on same cases and it gave the correct answer but now don’t know why printing garbage value. And yeah, no need of set and that’s why coded this http://ideone.com/OOQUBQ and with the same logic it gets accepted! The mistake I figured out was in the line s1.size() This isn’t returning the correct size of set and I wonder why it is such. I have commented the same line in the code. Any ideas why?? :o
However, see the execution timings of my submission codes http://www.codechef.com/status/GALACTIK,damn_me The minimum time is of the one using set in which i have inserted in the set :P.