Hey guys ! I kind of need your help to understand why I can't get past a test on this problem:
http://mirror.codeforces.com/contest/611/problem/H
It fails on test 3. I've extracted that test, ran it with my solution and to me it seems nothing is wrong. The checker reports "Graph is not connected", which is weird because if you check the output, it IS connected. Every node is connected to either node 1 or node 10, and nodes 1 and 10 are connected with each other.
My solution:
http://mirror.codeforces.com/contest/611/submission/15219155
Input of Test 3:
My solution's output to Test 3:
You have undefined behavior. For me locally (on my computer) your program indeed prints a correct output, the same you uploaded in pastebin. But try to run your program using "Custom Invocation". There you print an edge
100 10
and you don't print anything with110
. Last lines of your output in CF:"Custom invocation" shows only some number of first lines of the output. So, to see last lines you can change
for (int i = 0; i < sol.size(); ++i)
tofor (int i = 80; i < sol.size(); ++i)
I've looked through your output using "custom invocation" tab, your solution prints edge "10 100" twice: on 2nd line and on 100th line. Looks like there is a bug somewhere.
Thanks a lot to both of you for that find. The problem was with the line
(int)pow(10,x)
which was my way of getting a power of 10. It can evaluate to 99.9999.. which rounds down to 99.congratulation on getting AC!
Thanks !