No.1587 012 Matrix
Problem Statement
There is a grid with $N$ rows and $N$ columns (here, $N$ is even). yuki wants to write $0$, $1$, or $2$ in each cell. In doing so, the following condition must be satisfied.
- Let $A_i$ be the sum of the integers written in the $i$-th row from the top $(1 \leq i \leq N)$.
- Let $B_j$ be the sum of the integers written in the $j$-th column from the left $(1 \leq j \leq N)$.
- Then, the $2N$ integers $A_1, A_2, \cdots, A_N, B_1, B_2, \cdots, B_N$ are pairwise distinct.
Input
$N$
Output
If it is impossible to write $0, 1, 2$ in the cells so that the condition is satisfied, output No.
If it is possible, output $1$ way of writing them that satisfies the condition, in the following format.
$s_{1, 1}$$s_{1, 2}$$\cdots$$s_{1, N}$
$s_{2, 1}$$s_{2, 2}$$\cdots$$s_{2, N}$
$\vdots$
$s_{N, 1}$$s_{N, 2}$$\cdots$$s_{N, N}$
Here, $s_{i, j}$ is the integer written in the cell at the $i$-th row from the top and the $j$-th column from the left.If there are multiple solutions, any of them will be accepted.
Constraints
- $2 \leq N \leq 500$
- $N$ is even
Sample
Sample 1
Input
2
Output
01 22
The sum $A_1$ of the integers written in the $1$-st row from the top is $0 + 1 = 1$.
The sum $A_2$ of the integers written in the $2$-nd row from the top is $2 + 2 = 4$.
The sum $B_1$ of the integers written in the $1$-st column from the left is $0 + 2 = 2$.
The sum $B_2$ of the integers written in the $2$-nd column from the left is $1 + 2 = 3$.
They are all distinct, so this output is correct.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
e869120
沙耶花