問題一覧 > 通常問題

No.3508 OR Mapping

レベル : / AI推定難易度 : 2050 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : n_bitand_n_per_3 / テスター : Naru820 Nzt3 Solalyth
お気に入りにしたユーザー ProblemId : 13182 / 自分の提出
問題文最終更新日: 2026-04-17 18:01:35
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
CPCTF 2026: PPC (順位表) の他の問題:

Problem Statement

You are given a simple directed graph with $N$ vertices and $M$ edges, whose vertices are numbered from $1$ to $N$. The $i$-th edge is a directed edge from vertex $u_i$ to vertex $v_i$.

Each vertex can hold an integer between $0$ and $2^{K} - 1$, inclusive, and initially $0$ is written on every vertex.

There is $1$ piece placed on vertex $1$. There is also a variable $T$, initially $T = 0$.

You may repeat the following operation as many times as you like.

  • Let vertex $i$ be the vertex where the piece is currently placed. Choose a vertex $j$ such that there is an edge from vertex $i$ to vertex $j$, and move the piece to vertex $j$. Then, after adding $1$ to $T$, let $x$ be the value written on vertex $j$, and rewrite $x$ to $x\ \text{OR}\ (T \bmod 2^{K})$. Here, $A\ \text{OR}\ B$ denotes the bitwise OR of $A$ and $B$.

Your goal is to make the value written on every vertex equal to $2^K-1$. Determine whether this is possible.

Constraints

  • $1 \le N \le 5 \times 10^5$
  • $0 \le M \le \min \left( N(N-1) ,5 \times 10^5 \right)$
  • $1 \le K \le 51$
  • $1\le u_i , v_i \le N$
  • $u_i \ne v_i$
  • $i \ne j \Rightarrow (u_i,v_i) \ne (u_j,v_j)$
  • All input values are integers.

Input

The input is given from Standard Input in the following format.
$N$ $M$ $K$
$u_1$ $v_1$
$u_2$ $v_2$
$\vdots$
$u_M$ $v_M$

Output

Print Yes if it is possible, and No otherwise, on a single line.

Sample

Sample 1
Input
3 3 2
1 2
2 3
3 1
Output
Yes

Let $A$ be the sequence of numbers written on the vertices, in the order of vertices $1,2,3$.

  • Move the piece from vertex 1 to vertex 2. $A = (0, 1, 0)$ results.
  • Move the piece from vertex 2 to vertex 3. $A = (0, 1, 2)$ results.
  • Move the piece from vertex 3 to vertex 1. $A = (3, 1, 2)$ results.
  • Move the piece from vertex 1 to vertex 2. $A = (3, 1, 2)$ results.
  • Move the piece from vertex 2 to vertex 3. $A = (3, 1, 3)$ results.
  • Move the piece from vertex 3 to vertex 1. $A = (3, 1, 3)$ results.
  • Move the piece from vertex 1 to vertex 2. $A = (3, 3, 3)$ results.

By moving in this way, the values written on all vertices can be made 3, so the answer is Yes.

Sample 2
Input
3 3 2
1 2
2 3
1 3
Output
No

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