By Abner Samuel P. Palmeira, IFSULDEMINAS Brazil
Given a grid with its initial values set to zero and Q queries of the types:
1 x y: Places the value one at the position (x, y) of the board.
2 x y: Set the value zero to the (x, y) position of the board.
3 x y d: Returns the sum of two values of all positions of the board that are from a Manhattan distance of at most D from the position (x, y).
The first line contains an integer Q(1 ≤ Q ≤ 105).
The next Q lines contain queries as described earlier.
(0 ≤ X, Y, D ≤ 105)
For each query of type three print the sum of all the positions of the board that are from a Manhattan distance of at most D from the position (x, y).
Input Sample | Output Sample |
12 1 2 2 3 2 2 1 1 2 3 1 2 1 3 2 2 1 1 3 2 1 1 2 1 3 3 3 2 2 1 3 2 2 2 2 2 2 3 2 2 2 |
1 3 5 6 5 |