So I was solving problem D from the latest contest when I encounter a bizarre behavior. In this 306416672 the output to the second testcase is clearly incorrect.
The jury's answer is 0 2 4 2
My code's output is 0 2 4 4
Well, my code output the exact same thing as the jury in on my pc. Maybe an uninitialized variable?? No worries, it's the first testcase, I can just debug using the jury's output. In this 306417865 I print some additional variables to debug my code. The output is the line where there is only 1 integer, otherwise that line is a debug.
This time the answers came out to be (numbers in bold) 8 11 **0** 13 11 6 4 2 5 **2** 27 11 **4** 15 11 4 4 0 5 **2**
It's the correct answer, but I changed nothing except the debug line. Then I removed the debug line and the answers became wrong again. At this point I don't even know what to do so I add some random cout << " ";
to the code. And, amazingly, it worked. WHYYYYYYYYYYYYYYYYYYYY.