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

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

A couple of days ago I was participating in CF Round 374 and my solution failed the system testing, the verdict was Runtime Error on test 48. After the contest I copied the test case and run it on my machine using C++11. To my surprise the program terminated and produced what seemed to be a reasonable answer. I decided to send the same code with C++14 and it got Accepted.

Now, because I thought that CF would get mad at me for trying to send the same source code as before, I went ahead and added a random comment line at the top and submitted using C++11. The solution passed. After some more experimenting I found that depending on what you write as the comment string you get different verdicts.

The original submission: 21030683

Other people have submitted the same code and got Accepted even with C++11: 21074703, 21093103, 21094407.

I would appreciate if someone could provide an explanation for this because I am baffled :D. I posted essentially the same thing in the contest thread, but I don't think it got enough exposure. Hopefully someone who knows the ways of C++ can answer this :).

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

»
8 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

"index out of bounds" is undefined behavior, not weird one. Use valgrind to catch this error

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

It is not true that size of order is at least n - 1. In this test its size is 10 (vertices 4, 5 are unreachable from 1), but n = 12. So you perform out of bounds access to order. Fixed submissiobn (still can't be sure that is the only bug, though): 21120128.

»
7 лет назад, # |
  Проголосовать: нравится -21 Проголосовать: не нравится

Index out of bound!! "runtime error"!!!!