問題一覧 > 通常問題

No.2664 Prime Sum

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 135
作問者 : suisen / テスター : 👑 p-adic cureskol ygussany
お気に入りにしたユーザー ProblemId : 10366 / 自分の提出
問題文最終更新日: 2024-01-05 15:02:19
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 420 (順位表) の他の問題:

Problem Statement

You are given a positive integer $n$ and $m$ integer pairs $(a _ i, b _ i)\ (i = 1, 2, \ldots, m)$.

Here, $a _ i,b _ i$ are integers between $1$ and $n$, inclusive, and it is guaranteed that $a _ i \neq b _ i$.

Determine whether there exists a sequence $X = (X _ 1, X _ 2, \ldots, X _ n)$ of length $n$ that satisfies all of the following conditions.

  • For all $i = 1, 2, \ldots, n$, $X _ i$ is an integer greater than or equal to $2$
  • For all $i = 1, 2, \ldots, m$, $X _ {a _ i} + X _ {b _ i}$ is a prime number

Input

The input is given from Standard Input in the following format.

$n\ m$
$a _ 1\ b _ 1$
$a _ 2\ b _ 2$
$\vdots$
$a _ m\ b _ m$
  • All input values are integers
  • $2\leq n\leq 100$
  • $1\leq m\leq \dfrac{n(n-1)}{2}$
  • $1\leq a _ i, b _ i\leq n$
  • $a_i\neq b_i$ for all integers $i$ such that $1\leq i\leq m$
  • $(a_i,b_i)\neq (a_j,b_j)$ and $(a_i,b_i)\neq (b_j,a_j)$ for all integers $i,j$ such that $1\leq i\lt j\leq m$

Output

If $X$ satisfying the conditions exists, print Yes; otherwise, print No. Print the answer on $1$ line, followed by a newline.

Sample

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

The input represents $n = 4,\ m = 4, (a _ 1, b _ 1) = (1, 2),\ (a _ 2, b _ 2) = (2, 3),\ (a _ 3, b _ 3) = (3, 4),\ (a _ 4, b _ 4) = (4, 1)$.

For example, taking $X = (2,3,8,5)$ does satisfy the conditions, so print Yes as the answer.

Sample 2
Input
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
Output
No

It can be proved that no $X$ satisfying the conditions exists.

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