luogu#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?

输入格式

The first line contains two integers n,mn,m representing the height and width of the matrix.

The next nn lines contain mm integers each, representing the matrix AA.

The last line contains two integers r,sr,s.

输出格式

There are nr+1n-r+1 rows, each row has ms+1m-s+1 numbers, and the number in the iith row and jjth column represents the maximum value of the r×sr\times s submatrix element with (i,j)(i,j) as the upper left corner, that is, $\max\limits_{i\leq x\leq i+r-1,j\leq y\leq j+s-1}A_{x,y}$.

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