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

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

I was solving Div.2 116B using GNU C++11 and getting WA for test case 41. After changing the language to GNU C++17, my code was accepted.My question is why I got WA even though there was nothing wrong with the code. I also checked with C ++ 4.3.2 on ideone and got the correct answer for that test case.A very simple code having only loops and arrays..... what makes it WA in C++11.

WA : GNU C++11 submission

Accepted : GNU C++17 submission

Thank you.

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

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

Here: if(A[a][b]=='W') if a or b is 10 you read uninitialized memory.

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

    then should it be also wrong in c++17?

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

      Why does the output have to be wrong? Wrong code often produces right answers. Reading uninitialized memory is undefined behavior, so anything can happen including your program appearing to work.