A9546 | Nanami's Digital Board
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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?
输入格式
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.
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.
输出格式
For each query, print a single line containing one integer — the answer to Nanami's query.
输入输出样例
输入 #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
输出 #1
0 2 6
输入 #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
输出 #2
6 3 3
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted