C++17 Undefined Behavior

Правка en1, от Atomsky, 2021-06-21 05:38:23

In CF Round #727 (Div. 2), I submitted 120147862 for Problem-C: Stable Groups. It gave a wrong result on test 62 in GNU C++17. When I submitted the same code in GNU C++11, it was accepted (120149347).

I tried to figure out what went wrong in C++17. If I simply add a line that prints out the array output after line 14, like cout << foo[i] << endl;, the code gives the correct result in C++17. I am having trouble understanding why this might happen! What can I do in such cases?

Теги gnu c++17 vs gnu c++11

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Atomsky 2021-06-21 05:38:23 534 Initial revision (published)