Md_Abu_Taleb's blog

By Md_Abu_Taleb, history, 22 months ago, In English

problem link

HERE this solution accepted in c++17 but https://codeforces.me/contest/1971/submission/290780147 runtime error in c++20/23 i found similar problem same code WA in test 1 int 17 and WA in 2nd test in c++20 !!

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

| Write comment?
»
22 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Well, the compiler is right. Undefined behavior means that the code can have any result. Btw, if I use custom invocation of your accepted solution under c++17 on this test

1
10 1 11
10
1
9
8
1
10
7
0
2
6
5
4
3

then I will get: https://imgur.com/a/haQfRI3, which is obliviously WA.