Predecessor of begin of set lead to accepted, why?

Revision en1, by rumike, 2024-06-05 12:28:53

I was resolving 1922D - Berserk Monsters, and I found that access to the prev of beginning of set doesn't through wrong and can't get why.

First as you can see in that sumbmission that give wrong answer 264232760, I put the defense of border element at N = 2e9 + 5, and their attacks at 0 so they can't die neither attack. I took that value because 2*1e9 < N.

But in the editorial the took INT_MAX which is 2147483647 and it worked as you see here 264232643. I could not get why it's working, and after some times, I remark that if for the example the border 0 is in live set, it would be at the beginning of the set, and the code tried to access to predecessor of it, after and got the predecessor, it use that value as array index, which would normally leads to runtime error, but I get it gave a value which can be more than 1e9, it's for that reason N = 2e9 + 5 is not sufficient to prevent border to die. But can someone explain why predecessor of the beginning of a set doesn't lead to runtime error, and why it's work?

Tags runtime error, predecessor, set

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English rumike 2024-06-05 12:31:43 10 Tiny change: 'r to die. But can someone' -> 'r to die. \n\nCan someone'
en2 English rumike 2024-06-05 12:30:27 8
en1 English rumike 2024-06-05 12:28:53 1098 Initial revision (published)