harkirat's blog

By harkirat, history, 5 years ago, In English

Hello!

Can anyone explain why my submission: 77862595 to the problem: 1340B - Настя и табло is giving a RUNTIME_ERROR with exit code 2147483647 ? It works correctly on my macOS's Zsh terminal.

I tried to get a better understanding using a few online compilers:

  1. cpp.sh Exit code: 0 (normal program termination)

  2. onlinegdb.com *** Error in `./a.out': double free or corruption (out): 0x00000000024daec0 *** ( Note: the address is different every time)

  3. repl.it double free or corruption (out) exited, aborted

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What a pity! I don’t know why neither. I think you should check your code again.

»
5 years ago, # |
  Vote: I like it +14 Vote: I do not like it

In main, one of your loops has a condition of while(k>0 && i>=0), but then inside the loop you have i--;. This causes i to be -1 and then when it is used as an index, that causes undefined behavior.