No.1399 World Travel by Sugoroku (Construction)
タグ : / 解いたユーザー数 95
作問者 :
CuriousFairy315
/ テスター :
yosswi414
Problem Statement
315-san is playing a single-player board game.
This board game is played using $V$ vertices, one piece, and a sheet of paper divided into a grid of size $V \times V$.
Numbers are written on the paper, and the number written in the cell at the $i$-th row from the top and the $j$-th column from the left is $E_{i,j}$.
If the piece is placed on vertex $i$ and $E_{i,j}=1$, the piece can be moved to vertex $j$ on the next turn.
315-san must move the piece every turn.
Find one way of writing numbers on the paper such that, by moving the piece appropriately, no matter which vertex the piece starts on, the vertex where the piece is located after $D$ turns can be freely chosen to be any vertex.
There are multiple such answers, but only those that minimize the number of sets $\{i, j\}$ with $E_{i,j}=1$ are treated as correct.
Input
$V$ $D$
- $1 \leq V \leq 1000$
- $1 \leq D \leq 640000$
- All inputs are integers
Output
Output the matrix $E$ of size $V\times V$.
Here, $E_{i, j}$ is 1 if the piece can be moved from vertex $i$ to vertex $j$ in one turn, and 0 otherwise.
Also, $E_{i, j} = E_{j, i}$ must be satisfied for any $i, j$.
Print a newline at the end.
Sample
Sample 1
Input
3 3
Output
011 101 110
From any vertex, any vertex can be reached in $3$ moves.
- $1 \rightarrow 2 \rightarrow 3 \rightarrow 1$
- $1 \rightarrow 2 \rightarrow 3 \rightarrow 2$
- $1 \rightarrow 3 \rightarrow 2 \rightarrow 3$
- $2 \rightarrow 1 \rightarrow 3 \rightarrow 1$
- $2 \rightarrow 3 \rightarrow 1 \rightarrow 2$
- $2 \rightarrow 3 \rightarrow 1 \rightarrow 3$
- $3 \rightarrow 1 \rightarrow 2 \rightarrow 1$
- $3 \rightarrow 2 \rightarrow 1 \rightarrow 2$
- $3 \rightarrow 1 \rightarrow 2 \rightarrow 3$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。