#P5152. Pirate's Treasure Cave
Pirate's Treasure Cave
Pirate's Treasure Cave
You are given a pirate's cave represented as an n×n
grid where every cell initially contains 0 treasures. The pirate captain hides treasures in rectangular regions and then wants to check the parity of the total number of treasures in specified rectangular regions.
There are two types of operations:
- Update Operation:
1 x1 y1 x2 y2 k
. Addk
treasures to every cell in the subgrid with top-left coordinate(x1,y1)
and bottom-right coordinate(x2,y2)
. - Query Operation:
2 x1 y1 x2 y2
. Compute the sum $$ S = \sum_{i=x_1}^{x_2} \sum_{j=y_1}^{y_2} a_{i,j}, $$ and output "Odd" ifS mod 2 = 1
and "Even" ifS mod 2 = 0
.
Note: The grid indices are 1-indexed.
inputFormat
The first line contains two integers n
and q
(1 ≤ n ≤ 500 and q is the number of operations).
Each of the next q
lines contains an operation in one of the following formats:
- Update:
1 x1 y1 x2 y2 k
(1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n, and k is an integer). - Query:
2 x1 y1 x2 y2
(1 ≤ x1 ≤ x2 ≤ n and 1 ≤ y1 ≤ y2 ≤ n).
outputFormat
For each query operation, output a single line containing either "Odd" or "Even" depending on the parity of the sum of treasures in the specified subgrid.
sample
3 4
1 1 1 2 2 1
2 1 1 3 3
1 2 2 3 3 3
2 2 2 3 3
Even
Odd
</p>