Codeforces Round 248 (Div. 2)
D
Nanami's Digital Board
Codeforces
2000
原题
← CE →
翻译中…

Nanami is an expert at playing games. This day, Nanami's good friend Hajime invited her to watch a game of baseball. Unwilling as she was, she followed him to the stadium. But Nanami had no interest in the game, so she looked around to see if there was something that might interest her. That's when she saw the digital board at one end of the stadium.

翻译中…

The digital board is $*n*$ pixels in height and $*m*$ pixels in width, every pixel is either light or dark. The pixels are described by its coordinate. The $*j*$-th pixel of the $*i*$-th line is pixel $(*i*, *j*)$. The board displays messages by switching a combination of pixels to light, and the rest to dark. Nanami notices that the state of the pixels on the board changes from time to time. At certain times, certain pixels on the board may switch from light to dark, or from dark to light.

翻译中…

Nanami wonders, what is the area of the biggest light block such that a specific pixel is on its side. A light block is a sub-rectangle of the board, in which all pixels are light. Pixel $(*i*, *j*)$ belongs to a side of sub-rectangle with $(*x*_{1}, *y*_{1})$ and $(*x*_{2}, *y*_{2})$ as its upper-left and lower-right vertex if and only if it satisfies the logical condition:

翻译中…

(($*i* = *x*_{1}$ or $*i* = *x*_{2}$) and ($*y*_{1} ≤ *j* ≤ *y*_{2}$)) or (($*j* = *y*_{1}$ or $*j* = *y*_{2}$) and ($*x*_{1} ≤ *i* ≤ *x*_{2}$)).

翻译中…

Nanami has all the history of changing pixels, also she has some questions of the described type, can you answer them?

翻译中…

Input

翻译中…

The first line contains three space-separated integers $*n*$, $*m*$ and $*q* (1 ≤ *n*, *m*, *q* ≤ 1000)$ — the height and width of the digital board, and the number of operations.

翻译中…

Then follow $*n*$ lines, each line containing $*m*$ space-separated integers. The $*j*$-th integer of the $*i*$-th line is $*a*_{*i*, *j*}$ — the initial state of pixel $(*i*, *j*)$.

翻译中…
  • If $*a*_{*i*, *j*} = 0$, pixel $(*i*, *j*)$ is initially dark.
  • If $*a*_{*i*, *j*} = 1$, pixel $(*i*, *j*)$ is initially light.
翻译中…

Then follow $*q*$ lines, each line containing three space-separated integers $*op*$, $*x*$, and $*y* (1 ≤ *op* ≤ 2; 1 ≤ *x* ≤ *n*; 1 ≤ *y* ≤ *m*)$, describing an operation.

翻译中…
  • If $*op* = 1$, the pixel at $(*x*, *y*)$ changes its state (from light to dark or from dark to light).
  • If $*op* = 2$, Nanami queries the biggest light block with pixel $(*x*, *y*)$ on its side.
翻译中…

Output

翻译中…

For each query, print a single line containing one integer — the answer to Nanami's query.

翻译中…

Note

翻译中…

Consider the first sample.

翻译中…

The first query specifies pixel $(2, 2)$, which is dark itself, so there are no valid light blocks, thus the answer is 0.

翻译中…

The second query specifies pixel $(1, 2)$. The biggest light block is the block with $(1, 2)$ as its upper-left vertex and $(1, 3)$ as its lower-right vertex.

翻译中…

The last query specifies pixel $(2, 2)$, which became light in the third operation. The biggest light block is the block with $(1, 2)$ as its upper-left vertex and $(3, 3)$ as its lower-right vertex.

翻译中…

样例

Input #1
3 4 5
0 1 1 0
1 0 0 1
0 1 1 0
2 2 2
2 1 2
1 2 2
1 2 3
2 2 2
Output #1
0
2
6
InputCopy OutputCopy
Input #2
3 3 4
1 1 1
1 1 1
1 1 1
2 2 2
1 2 2
2 1 1
2 2 1
Output #2
6
3
3
InputCopy OutputCopy
题目信息
题号
433D
时间限制
1 s
内存限制
256 MB
标签
并查集
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。