Codeforces Round 822 (Div. 2) |
---|
Finished |
You are given a prime number $$$n$$$, and an array of $$$n$$$ integers $$$b_1,b_2,\ldots, b_n$$$, where $$$0 \leq b_i < n$$$ for each $$$1 \le i \leq n$$$.
You have to find a matrix $$$a$$$ of size $$$n \times n$$$ such that all of the following requirements hold:
Here $$$x \not \equiv y \pmod m$$$ denotes that $$$x$$$ and $$$y$$$ give different remainders when divided by $$$m$$$.
If there are multiple solutions, output any. It can be shown that such a matrix always exists under the given constraints.
The first line contains a single positive integer $$$n$$$ ($$$2 \le n < 350$$$).
The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i < n$$$) — the required values on the main diagonal of the matrix.
It is guaranteed that $$$n$$$ is prime.
Print $$$n$$$ lines. On the $$$i$$$-th line, print $$$n$$$ integers $$$a_{i, 1}, a_{i, 2}, \ldots, a_{i, n}$$$, each separated with a space.
If there are multiple solutions, output any.
2 0 0
0 1 0 0
3 1 1 1
1 2 2 1 1 0 1 0 1
5 1 4 1 2 4
1 0 1 3 4 1 4 3 1 0 2 4 1 0 2 1 2 2 2 2 2 2 0 1 4
In the first example, the answer is valid because all entries are non-negative integers less than $$$n = 2$$$, and $$$a_{1,1}+a_{2,2} \not\equiv a_{1,2}+a_{2,1} \pmod 2$$$ (because $$$a_{1,1}+a_{2,2} = 0 + 0 \equiv 0 \pmod 2$$$ and $$$a_{1,2}+a_{2,1} = 1 + 0 \equiv 1 \pmod 2 $$$). Moreover, the values on the main diagonals are equal to $$$0,0$$$ as required.
In the second example, the answer is correct because all entries are non-negative integers less than $$$n = 3$$$, and the second condition is satisfied for all quadruplets $$$(r_1, r_2, c_1, c_2)$$$. For example:
Name |
---|