CF433D.Nanami's Digital Board
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
纳米米是一名游戏高手。这一天,纳米米的好朋友一诚邀请她去观看一场棒球比赛。尽管不太情愿,她还是跟着他来到了体育场。但纳米米对比赛毫无兴趣,于是环顾四周,想看看有没有什么能引起她注意的东西。就在这时,她看到了体育场一端的数字显示屏。
该数字显示屏高为 n 像素、宽为 m 像素,每个像素非亮即暗。像素通过其坐标来描述:第 i 行第 j 列的像素记为 (i,j)。显示屏通过将某些像素设为亮、其余像素设为暗来显示信息。纳米米注意到,显示屏上像素的状态会随时间而变化。在某些时刻,显示屏上的某些像素可能会由亮变暗,或由暗变亮。
纳米米好奇:以某个指定像素位于其某条边上的最大亮色矩形区域的面积是多少?
所谓“亮色矩形区域”,是指显示屏的一个子矩形区域,其中所有像素均为亮色。
像素 (i,j) 属于以 (x1,y1) 为左上角顶点、(x2,y2) 为右下角顶点的子矩形的一条边,当且仅当它满足如下逻辑条件:
((i=x1 或 i=x2) 且 y1≤j≤y2)或((j=y1 或 j=y2) 且 x1≤i≤x2).
纳米米已掌握所有像素状态变更的历史记录,同时也提出了一些上述类型的问题。你能回答它们吗?
输入格式
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.
第一行包含三个以空格分隔的整数 n、m 和 q(1 ≤ n, m, q ≤ 1000)——分别表示数字显示屏的高度、宽度以及操作次数。
接下来是 n 行,每行包含 m 个以空格分隔的整数。第 i 行的第 j 个整数为 ai,j —— 表示像素 (i,j) 的初始状态。
- 若 ai,j=0,则像素 (i,j) 初始为暗色;
- 若 ai,j=1,则像素 (i,j) 初始为亮色。
随后是 q 行,每行包含三个以空格分隔的整数 op、x 和 y(1 ≤ op ≤ 2;1 ≤ x ≤ n;1 ≤ y ≤ m),描述一次操作。
- 若 op=1,则像素 (x,y) 翻转其状态(由亮变暗,或由暗变亮);
- 若 op=2,Nanami 查询以像素 (x,y) 为其一条边上的点的最大亮色连通块的面积。
输出格式
For each query, print a single line containing one integer — the answer to Nanami's query.
对于每个查询,输出一行,包含一个整数——即 Nanami 查询的答案。
输入输出样例
输入#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.
考虑第一个样例。
第一个查询指定像素 (2,2),该像素本身为暗色,因此不存在合法的亮色块,答案为 0。
第二个查询指定像素 (1,2)。最大的亮色块是以 (1,2) 为左上角顶点、(1,3) 为右下角顶点的块。
最后一个查询指定像素 (2,2),该像素在第三次操作后变为亮色。最大的亮色块是以 (1,2) 为左上角顶点、(3,3) 为右下角顶点的块。
输入解题思路,AI测评打分。不知道怎么写?