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
You are accessing outside the bound of $$$ans$$$. This is undefined behavior.
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
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)$$$.
you are saying its completely random that it may get accepted or not,because of the undefined behaviour?
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