#P9905. [COCI 2023/2024 #1] AN2DL

[COCI 2023/2024 #1] AN2DL

题目描述

While wandering around Building 2121, you came across a wall completely covered with numbers, arranged in a table of nn rows and mm columns. Soon you noticed that there was a frame leaning against the wall large to frame rr rows and ss columns of the table on the wall. And next to the frame you found a pencil and a piece of paper containing an empty table.

You are sad that the table on the piece of paper is empty, so you decided to play around with the frame to fill it.

You leaned the frame against the wall so that the number in the ii-th row and jj-th column is in the upper left corner, and the borders of the frame are parallel to the edges of the wall. Considering the numbers inside the frame, and since you like large numbers, you have decided to write the largest among them in the ii-th row and jj-th column of the table on the piece of paper.

You repeated the process for every possible position of the frame on the wall (such that the frame is entirely on the wall, and that there are exactly r×sr \times s numbers inside it), making sure that the edges of the frame are parallel to the edges of the wall.

When you were done, the table on the piece of paper was even more beautiful than the one on the wall.What numbers are in the table on the piece of paper?

题目大意

给定 n,m,r,sn,m,r,s 和一个 n×mn\times m 的整数矩阵 AA,求它每个 r×sr\times s 的子矩阵的元素最大值。

输入格式

第一行两个整数 n,mn,m 表示矩阵的高和宽。

接下来 nn 行每行 mm 个整数,表示矩阵 AA

最后一行两个整数 r,sr,s

输出格式

nr+1n-r+1 行,每行 ms+1m-s+1 个数,第 iijj 列的数表示以 (i,j)(i,j) 为左上角的 r×sr\times s 的子矩阵元素的最大值,即 $\max\limits_{i\leq x\leq i+r-1,j\leq y\leq j+s-1}A_{x,y}$。

题目大意

给定 n,m,r,sn,m,r,s 和一个 n×mn\times m 的整数矩阵 AA,求它每个 r×sr\times s 的子矩阵的元素最大值。

3 3
1 1 2
2 3 4
4 3 2
3 3
4
3 3
1 1 2
2 3 4
4 3 2
2 1
2 3 4
4 3 4
5 5
-1 -3 -4 -2 4
-8 -7 -9 -10 11
5 2 -8 -2 1
13 -3 -2 -6 -9
11 6 2 7 4
2 3
-1 -2 11
5 2 11
13 2 1
13 7 7

提示

【样例解释#1】

只有一个 3×33\times 3 的子矩阵,且是整个矩阵,它的元素最大值是 44

【样例解释#2】

矩阵和它的每个 2×12\times 1 的子矩阵如下图所示,其中标红的数为最大值:

【数据范围】

对于 100%100\% 的数据,1n,m40001\leq n,m\leq 4000Ai,j10000\lvert A_{i,j}\rvert\leq 100001rn1\leq r\leq n1sm1\leq s\leq m

本题采用捆绑测试。

子任务 特殊性质 分值
11 n,m40n,m\leq 40r=nr=ns=ms=m 1212
22 n,m40n,m\leq 40 1717
33 n,m1000n,m\leq 1000 2525
44 无特殊性质 5656

【说明】

本题分值按 COCI 原题设置,满分 110110

题目译自 COCI2022-2023 CONTEST #1 T3 AN2DL