#P5910. [CTSC2007] 矩阵Matrix 【征集 SPJ】
[CTSC2007] 矩阵Matrix 【征集 SPJ】
Problem Description
Given an integer and a real matrix with rows and columns, the element in row and column is , and (, ). You are asked to provide an matrix , whose element in row and column is (, ), where is either or .
For the given matrix and your matrix , we can compute:
$$p_1=\max \begin{cases}\max\limits_{ 1 \le j \le m} \{ |\sum_{i=1}^n (b_{ij}-\frac{a_{ij}}{D})|\}\\\max\limits_{1 \le i \le n} \{ |\sum_{j=1}^m (b_{ij}-\frac{a_{ij}}{D})|\}\end{cases}$$$$p_2=\max_{1 \le i \le n,1 \le j \le m} \{|b_{i,j}+b_{i-1,j}+b_{i,j-1}+b_{i-1,j-1}-\frac{a_{i,j}+a_{i-1,j}+a_{i,j-1}+a_{i-1,j-1}}{D}|\}$$For different test cases, we hope that the matrix you provide can make or as small as possible.
Input Format
The first line contains an integer , which has two possible values: means our minimization target is , and means we want to be as small as possible.
The second line contains three integers , , and , separated by a single space. The meaning of is as described above, and and are the number of rows and columns of matrix , respectively.
Then follow lines, each containing real numbers describing matrix . The real number in row and column is , and adjacent numbers are separated by a single space.
Output Format
Output only an matrix , representing the answer you found that makes as small as possible. The number in row and column is . Adjacent integers are separated by a single space.
1
7 3 4
1 6 4 6
7 0 3 3
2 5 1 5
0 1 0 1
1 0 1 0
0 1 0 1
2
7 3 4
1 6 4 6
7 0 3 3
2 5 1 5
0 1 0 1
1 0 1 0
0 1 0 1
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, Constraints: , .
Translated by ChatGPT 5