In the editorial because I couldn’t figure out how to solve the problem. I don’t understand why you would set the corners to -1.
Block Spoilers
Suppose you have a 7\times 7 array.
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Suppose you paint from (1,1), (5,5). These are the corners of the square.
According to the editorial, it would be
0 0 0 0 0 0 0
0 1 0 0 0 -1 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 -1 0 0 0 1 0
0 0 0 0 0 0 0
Applying the prefix sum,
0 0 0 0 0 0 0
0 1 1 1 1 0 0
0 1 1 1 1 0 0
0 1 1 1 1 0 0
0 1 1 1 1 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
But, shouldn’t it be
0 0 0 0 0 0 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 0 0 0 0 0 0
So then, the answer will be wrong because the program will output 16 instead of 25?
Edit: Nevermind. I figured out that the points they give are coordinates.