RogueNinja's blog

By RogueNinja, history, 4 weeks ago, In English

Problem link

This problem is from recent Round #672 (Div. 2). I did a stupid miscalculation (-_-). One of the dimension-size of the array was supposed to be around 3200 but I assigned the size 160. But funny thing is it still got accepted (offline solve btw).

1st Submission link

Later I understood the mistake and submitted the code again which I think is correct. 2nd Submission link

Now, why 1st solution is accepted? Is this something which can be exploited again? Or am I just lucky as there's also another dimension after it which might've persisted the result without conflicting.

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

4 weeks ago, # |
Rev. 8   Vote: I like it +1 Vote: I do not like it

Well, this is c++, it does not check array boundaries and just accesses the memory by the address it computed from the dimensions and your indexes.

If calculated addresses are withing the range and did not overlap, I assume it is may be safe, though should not be done. If calculated addresses are outside of the range, then you are lucky if you don't corrupt anything important

In this case it seems you were lucky for the reason you mentioned