Yesterday when I was attending the CodeForces#100, I met a werid problem.
It was Problem A, I wrote my code, submitted, and passed the pretest, as usual. After the system test, I found that my code failed at test 9, it is:
Input: 2 1000 500
Output: NO
Answer: YES
status no. : 1011828
However, when I tested the data on my PC, I noticed that I' ve passed the test. My classmates told me that it might be the reason of O2 optimization of g++, because I don' t add that option on my PC, while CodeForces do. And Later on I submitted again with the MS Visual C++, this time my code was accepted(see status no. : 1010135), interesting, huh?
And something more interesting, if I add some "cout" before a statement(for debugging), I' ll pass the test in custom test:
See the status no. : 1011863
In this situation, I just add an cout << "" before I make my desicion.
And if I remove the cout << "":
I think this kind of results might have something with the O2 optimization, as the optimization may reduce the orders when it is compiling the source code.
Full text and comments »