WA in Galactik Football

Why this


[1] giving WA for [this][2] problem? 


  [1]: http://ideone.com/OqSHFi
  [2]: http://www.codechef.com/problems/GALACTIK

There are two bugs in your program

  1. 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.

  2. Secondly, your code is too slow, use scanf and printf for fast i/o and also there is no need of stl

set

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 OOQUBQ - Online C++ Compiler & Debugging Tool - Ideone.com 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 CodeChef: Practical coding for everyone The minimum time is of the one using set in which i have inserted in the set :P.