#P7515. [省选联考 2021 A 卷] 矩阵游戏
[省选联考 2021 A 卷] 矩阵游戏
Description
Alice has an matrix (, ), where each element is a non-negative integer with value at most .
Bob uses this matrix to generate an matrix (, ). Each element is generated by
$$b_{i, j} = a_{i, j} + a_{i, j + 1} + a_{i + 1, j} + a_{i + 1, j + 1}$$Now Alice has forgotten the matrix . Please restore from the matrix given by Bob.
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases. For each test case:
The first line contains two positive integers , the size of matrix .
The next lines each contain non-negative integers, representing .
Output Format
For each test case:
- If the matrix cannot be generated, output one line containing the string
NO. - If the matrix can be generated, first output one line containing the string
YES, then output lines each containing non-negative integers (separated by single spaces) with value at most , representing .
If multiple matrices can generate the given , output any one of them.
3
3 3
28 25
24 25
3 3
15 14
14 12
3 3
0 3000005
0 0
YES
7 8 8
8 5 4
4 7 9
YES
4 2 2
5 4 6
5 0 2
NO
Hint
Constraints
For all testdata: , , .
The detailed limits for each test point are shown in the table below:
| Test Point ID | Special Constraint | |
|---|---|---|
| None | ||
| None |
Translated by ChatGPT 5
京公网安备 11011102002149号