問題一覧 > 通常問題

No.1399 World Travel by Sugoroku (Construction)

レベル : / AI推定難易度 : 900 / 実行時間制限 : 1ケース 3.153秒 / メモリ制限 : 315 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 95
作問者 : CuriousFairy315 / テスター : yosswi414
お気に入りにしたユーザー ProblemId : 3565 / 自分の提出
問題文最終更新日: 2021-02-19 22:57:28
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 283 (順位表) の他の問題:

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$
In this case, the number of sets $\{i, j\}$ with $E_{i,j}=1$ is $3$ in total, namely $\{1, 2\}, \{1, 3\}, \{2, 3\}$, and this is the minimum.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。