ParanoidAndroid's blog

By ParanoidAndroid, history, 8 years ago, In English

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 :).

  • Vote: I like it
  • +16
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +13 Vote: I do not like it

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

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 years ago, # |
  Vote: I like it -21 Vote: I do not like it

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