CP_Sucks's blog

By CP_Sucks, history, 4 years ago, In English

I got RE with submitting in c++17 and same code AC in c++14. Why is it so can someone help.

C++14 https://codeforces.com/contest/1282/submission/67691308

C++17 https://codeforces.com/contest/1282/submission/67690121

  • Vote: I like it
  • +6
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Maybe because you didn't use cout.flush()

»
4 years ago, # |
  Vote: I like it -8 Vote: I do not like it

Just change query[len-1] with query.back()

»
4 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You're getting this verdict because you didn't exit immediately after printing the first query, which was the solution in that case. After that, your program will be reading from a closed stream, meaning that, for example resb will be uninitialized. The fact you passed this test case in c++14 was just pure luck.

Oh, and please put parentheses around n in your ffor macro, otherwise you'll get burned one day.