Блог пользователя Prabhi

Автор Prabhi, история, 5 лет назад, По-английски

In the latest rated contest i.e., Codeforces Round #632 (Div. 2)

I submitted a solution for question B, Contest link wherein I had declared arrays globally with a size 10^4+10 instead of 10^5+10 and it gave TLE on pretest 3. Here's the link to my submission

However, on submitting the same code with GNU C++14 and GNU C++17, I got the much expected result RE. Here's the link to the RE one

Can anyone explain as to why this happened?

Also, I would like MikeMirzayanov to look into this.

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Accessing an out-of-bounds index is undefined behavior. Compilers assume it never happens so if it does happen you get all sorts of weird crap. C++ assumes you know what you're doing unlike other languages such as Java and won't do a lot of error checking for you.