#P5791. [CTSC2006] 方块填数
[CTSC2006] 方块填数
Problem Description
Recently, a game of filling numbers in a grid has become popular worldwide.
You are given an grid. The rows are numbered from to from top to bottom, and the columns are numbered from to from left to right. If both the row number and the column number of a cell are odd, then the cell is called an odd cell. At the start of the game, all odd cells are already filled with numbers. You need to fill numbers into the other cells. If after filling, the grid satisfies the following conditions, you win the game:
- In every subgrid, the sum of all numbers is greater than .
- In every subgrid, the sum of all numbers is less than .
Here, are all given at the start of the game. An subgrid refers to the set of all cells whose row indices are from to , and whose column indices are from to .
Xiao P likes this game very much. He hopes you can help write a program to provide one way to fill the numbers, or tell him that such a way does not exist.
Input Format
The first line contains positive integers separated by spaces: .
Next, there are lines. Each line contains integers. The -th number on line represents the integer initially filled in the cell at row and column of the grid.
Output Format
If no filling scheme exists, output only one line: No.
If a filling scheme exists, first output one line: Yes. Then output lines, each containing integers separated by spaces, describing a filling scheme. Each output integer must be between and .
3 3 2 2 3 3
1 1
1 1
Yes
1 -1 1
-4 5 -4
1 -1 1
Hint
Sample Explanation

After filling, the sum of the numbers in any block is ; the sum of the numbers in any block is .
Constraints
For of the testdata, . The numbers already filled in the grid are all between and .
Translated by ChatGPT 5