#P3801. Scarlet Mist Conundrum
Scarlet Mist Conundrum
Scarlet Mist Conundrum
After the previous failure, Remilia decided to trigger the Scarlet Mist anomaly again. However, to avoid being defeated by Reimu, she released the mist in a peculiar formation.
We represent Gensokyo as an grid with no cells initially covered by the mist. Each time Remilia performs an operation at cell , she releases four infinite streams of red mist in the east, south, west, and north directions. These streams cover the entire corresponding row and column, except the cell where she stands. If two or more streams collide at a cell, they cancel out and vanish.
There are two types of operations:1 x y
: Remilia releases the mist at cell .2 x_1 y_1 x_2 y_2
: Query the number of cells in the subrectangle with top-left and bottom-right that are covered by exactly one mist stream.
A cell is considered covered by the mist if and only if exactly one mist stream affects it.
inputFormat
The first line contains three integers , , and , representing the number of rows, columns, and the number of operations respectively. The following lines each describe an operation. An operation is either:1 x y
(for mist release) or2 x1 y1 x2 y2
(for query).
outputFormat
For each operation of type 2, output the number of cells in the specified rectangular region that are covered by exactly one mist stream.
sample
3 3 3
1 2 2
2 1 1 3 3
2 2 2 2 2
4
0
</p>