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.
Accepted : GNU C++17 submission
Thank you.
Here:
if(A[a][b]=='W')
ifa
orb
is 10 you read uninitialized memory.then should it be also wrong in c++17?
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.