Md_Abu_Taleb's blog

By Md_Abu_Taleb, history, 47 hours 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

»
46 hours ago, # |
  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.

  • »
    »
    38 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But output correct though ! can you add a little explaination

    • »
      »
      »
      36 hours ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      ll ds = (a[id + 1] — a[id]); ll dt = (b[id + 1] — b[id]);

      in these line...the array goes out of bound...!!!(a[id + 1] =>> where id is k)..

      and here is the accepted solution code of your code...!!!