BLUmOOn's blog

By BLUmOOn, history, 3 weeks ago, In English

so my solution 262742856 had passes 8 pretests during live contest but after the contest was over,it gave run time error on test case 1.i changed my language to c++20 from c++17 and it got accepted,my question is why was it showing pretests passes during contest then?it is unfair to me.please see this Stefan2417 and alexchist

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

You are accessing outside the bound of $$$ans$$$. This is undefined behavior.

  • »
    »
    3 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    but why did it got accepted during live contest then?if it would have given runtime error then only,i would have checked for an error. Although,thanks for pointitng out the error. However ,it gets accepted when i submit it in c++20 instead of c++17

    • »
      »
      »
      3 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      but why did it got accepted during live contest then?

      Since this is undefined behavior, there is no explanation for whatever happened.

      If you want to use a safer alternative, there is $$$vec.at(index)$$$.

      • »
        »
        »
        »
        3 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        you are saying its completely random that it may get accepted or not,because of the undefined behaviour?

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

why am i getting downvotes?if i would have known my code is wrong i would have corrected it then only,but my code passes 8 test cases.it is unfortunate as i was getting positive delta and ended up getting negative delta