Adonis_'s blog

By Adonis_, history, 5 months ago, In English

I have a complain. I have solve Question B & C of Codeforces Round 931 & it was succesfully run in pretests, but after the contest it's showing runtime error. & submitting the same code after the contest it is succesfully accepted. Please tell me how it's happened. harsh__h

C: During Contest & after contest

B: During Contest & after contest

[Later Edited]: I have got the problem that it's due to vector size declaration of 30, but i am confused why it didn't give runtime error on test 1 instead of this later cases.

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

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Adonis_ (previous revision, new revision, compare).

»
5 months ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

You're right, both solutions are exactly the same character by character.

It could be because of an array out of bound, but I think CodeForces usually use -fsanitize=address to give a meaningful error, not just a random exit code.

Alse, it can be because of Operating System error that occurred during contest which can't be controlled. But it was unfair for you, and CF team should give an explanation.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes if the runtime error would have appear during the pretest I would have changed it, a penalty of -50 is far better than awarding 0. MikeMirzayanov Please look into this

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Because it is undefined behavior. Documentation

Portable programs should never call this function with an argument n that is out of range, since this causes undefined behavior.

A similar member function, vector::at, has the same behavior as this operator function, except that vector::at is bound-checked and signals if the requested position is out of range by throwing an out_of_range exception.

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Adonis_ (previous revision, new revision, compare).