#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

提示

COCI2022-2023 CONTEST #1 Problem 3. AN2DL