-->
当前位置:首页 > 题库

PROGRAMMING:The best matching matrix

Luz5年前 (2021-05-10)题库409
###Task description
```
Given a matrix A of M * N and a matrix B of R * s, where 0 < R ≤ m, 0 < s ≤ n, all elements of a and B are positive integers less than 100. Find a submatrix C with the size of R * s in a, so that the sum of absolute values of the differences between the corresponding elements of B and C is the smallest, then C is called the most matching matrix. If more than one submatrix satisfies the condition at the same time, select the one whose row number is smaller in the upper left corner of the submatrix, and select the one whose column number is smaller when the row number is the same.
```
###Input format:
```
The first line is m and N, separated by a space.
After M rows, each row has n integers, representing each row in the a matrix, and the numbers are separated by a space.
The M + 2 acts R and s, separated by a space.
After that, there are s integers in each row of R, which represent each row of B matrix, and the number is separated by a space.
(1 ≤ m ≤ 100,1 ≤ n ≤ 100)
```
###Output format:
```
Output matrix C, a total of R lines, each line s integers, integers separated by a space.
```
###Input example:
```in
3 3
3 4 5
5 3 4
8 2 4
2 2
7 3
4 9
```
###Output example:
```out
4 5
3 4
```
###Title Source
This topic is selected from openjudge website http://noi.openjudge.cn/ch0112/04/






answer:If there is no answer, please comment