P5791 [CTSC2006] Filling Numbers in a Grid
Description
Recently, a game of filling numbers in a grid has become popular worldwide.
You are given an $n \times m$ grid. The $n$ rows are numbered from $1$ to $n$ from top to bottom, and the $m$ columns are numbered from $1$ to $m$ 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:
1. In every $a_1 \times b_1$ subgrid, the sum of all numbers is greater than $0$.
2. In every $a_2 \times b_2$ subgrid, the sum of all numbers is less than $0$.
Here, $a_1, b_1, a_2, b_2$ are all given at the start of the game. An $a \times b$ subgrid refers to the set of all cells whose row indices are from $i\ (1 \leq i \leq n-a+1)$ to $i+a-1$, and whose column indices are from $j\ (1 \leq j \leq m-b+1)$ to $j+b-1$.
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 $6$ positive integers separated by spaces: $n, m, a_1, b_1, a_2, b_2$.
Next, there are $\lfloor \frac{n+1}{2} \rfloor$ lines. Each line contains $\lfloor \frac{m+1}{2} \rfloor$ integers. The $j\ (j=1, 2, \ldots, \lfloor \frac{m+1}{2} \rfloor)$-th number on line $i+1$ represents the integer initially filled in the cell at row $2i-1$ and column $2j-1$ 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 $n$ lines, each containing $m$ integers separated by spaces, describing a filling scheme. Each output integer must be between $-10^9$ and $10^9$.
Explanation/Hint
#### Sample Explanation

After filling, the sum of the numbers in any $2 \times 2$ block is $1$; the sum of the numbers in any $3 \times 3$ block is $-1$.
#### Constraints
For $100\%$ of the testdata, $1 \leq n, m, a_1, b_1, a_2, b_2 \leq 100$. The numbers already filled in the grid are all between $-100$ and $100$.
Translated by ChatGPT 5