No.1078 I love Matrix Construction
問題文最終更新日: 2020-05-19 17:47:44
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 252
(順位表)
の他の問題:
Problem Statement
You are given an integer $N$ and arrays $S,T,U$ of length $N$. Construct any 1 $N \times N$ matrix $a$ that satisfies the following conditions.
- $a_{i,j}$ is $0$ or $1$
- For all pairs $(i,j)$ such that $1 \le i,j \le N$, $a_{S_i,j}+a_{j,T_i} \times 2 \neq U_i$
Input
$N$ $S_1\ S_2\ \cdots\ S_N$ $T_1\ T_2\ \cdots\ T_N$ $U_1\ U_2\ \cdots\ U_N$
All inputs are integers
$1 \le N \le 500$
$1 \le S_i,T_i \le N$
$0 \le U_i \le 3$
Output
If a matrix satisfying the conditions exists, output $1$ such matrix in the following format.
$a_{1,1} \cdots\ a_{1,N}$
$\vdots$
$a_{N,1} \cdots\ a_{N,N}$
Note that you may output any matrix that satisfies the conditions.If no matrix satisfying the conditions exists, output
-1.
Sample
Sample 1
Input
3 2 1 2 3 3 1 3 1 0
Output
0 0 0 1 0 1 0 0 0
For example, for $(i,j)=(1,2)$, we have $a_{2,2}+a_{2,3} \times 2=2 \neq 3$, so the condition is satisfied.
Sample 2
Input
4 4 4 3 3 2 1 1 2 1 0 0 3
Output
-1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
tko919
QCFium