_BEAST_00_'s blog

By _BEAST_00_, history, 6 weeks ago, In English

hello everyone ; I am trying to solve this problem

https://codeforces.com/problemset/problem/791/A

and my submission is

https://codeforces.com/problemset/submission/791/162926301

The code is running and producing correct output for sample test cases in my local ide but in codeforces, I am getting Runtime error for sample testcase!!

Is there anything I am missing?

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

»
6 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

Dude, Codeforces even tells you a reason. Your function does not return anything in one of the cases. You should add a return keyword in front of a function call.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But why does it get accepted in c++17??

    • »
      »
      »
      6 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I hate that we cannot pin forever some blog like "What the undefined behaviour is and how not to fool yourself with "but it was accepted in my local/another server compilator"

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Surprisingly this works in GNU C++17

https://codeforces.com/contest/791/submission/162928846

Whereas fails with runtime error in C++20

https://codeforces.com/contest/791/submission/162929055

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

debug yourself

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can't figure out the exact reason