問題一覧 > 通常問題

No.1400 World Travel by Sugoroku

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 3.153秒 / メモリ制限 : 315 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 19
作問者 : CuriousFairy315 / テスター : yosswi414
お気に入りにしたユーザー ProblemId : 3785 / 自分の提出
問題文最終更新日: 2021-04-09 01:02:59
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.
Output Yes if, by moving the piece appropriately, from whichever vertex the piece starts, any vertex of your choice can be selected as the vertex where the piece is located after $D$ turns; otherwise, output No.
If, depending on how the piece is placed and moved, the piece may become unable to move partway through, output No.

Input

$V\ D$
$E_{1,1}\ \cdots\ E_{1,V}$
$\vdots$
$E_{V,1}\ \cdots\ E_{V,V}$

  • $1 \leq V \leq 2000$
  • $1 \leq D \leq 10^{18}$
  • $E_{i,j}$ is $0$ or $1$, and $E_{i,j}=1$ means that the piece can be moved from vertex $i$ to vertex $j$ in one turn
  • $E_{i,j}=E_{j,i}$
  • All inputs are integers

Output

Output Yes if the condition is satisfied, and No otherwise.
Print a newline at the end.

Sample

Sample 1
Input
3 3
011
101
110
Output
Yes

This is the same sample as the one used in World Travel by Sugoroku (Construction).

Sample 2
Input
6 5
000111
000111
000111
111000
111000
111000
Output
No

This is the complete bipartite graph $K_{3,3}$. It can be quickly verified that a bipartite graph does not satisfy the constraints.

Sample 3
Input
5 640000
00100
00100
11111
00100
00100
Output
Yes

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