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

Автор BLUmOOn, история, 6 месяцев назад, По-английски

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

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

»
6 месяцев назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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

    • »
      »
      »
      6 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        6 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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

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

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