Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя adfadfs

Автор adfadfs, история, 4 года назад, По-английски

I submitted the following two codes, which are essentially the same but one gives WA, the other got accepted.

WA code

AC code

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

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

This needs the attention of some experienced programmers. I have no clue about this.

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

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.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Thank You! I now realize that there's an overflow in the Mex array.

    Wow, assertions have some 'undefined behavior' benefits as well :P