acmsguru |
---|
Закончено |
125. Shtirlits time limit per test: 0.25 sec.
There is a checkered field of size N x N cells (1 Ј N Ј 3). Each cell designates the territory of a state (i.e. N2 states). Each state has an army. Let A [i, j] be the number of soldiers in the state which is located on i-th line and on j-th column of the checkered field (1£i£N, 1£j£N, 0 £ A[i, j] £ 9). For each state the number of neighbors, B [i, j], that have a larger army, is known. The states are neighbors if they have a common border (i.e. 0 £ B[i, j] £ 4). Shtirlits knows matrix B. He has to determine the number of armies for all states (i.e. to find matrix A) using this information for placing forces before the war. If there are more than one solution you may output any of them.
Input The first line contains a natural number N. Following N lines contain the description of matrix B - N numbers in each line delimited by spaces.
Output If a solution exists, the output file should contain N lines, which describe matrix A. Each line will contain N numbers delimited by spaces. If there is no solution, the file should contain NO SOLUTION.
Sample Input 3 1 2 1 1 2 1 1 1 0
Sample Output 1 2 3 1 4 5 1 6 7 | ||||||
|
Название |
---|