I submitted the following two codes, which are essentially the same but one gives WA, the other got accepted.
(compare the two solutions to see the differences)
UPD: Perhaps this is not something just random, repeating the submissions still gives the same verdicts. I am unsure how assertions are affecting the code.
This needs the attention of some experienced programmers. I have no clue about this.
You can see possible undefined behavior when choosing right compiler. What I get, submitting this code is: Probably, the solution is executed with error 'out of bounds' on the line 150.
Thank You! I now realize that there's an overflow in the Mex array.
Wow, assertions have some 'undefined behavior' benefits as well :P