問題一覧 > ネタ問題

No.8092 3-2-SAT

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 48
作問者 : stoq / テスター : 👑 Kazun
お気に入りにしたユーザー ProblemId : 7696 / 自分の提出
問題文最終更新日: 2022-02-13 02:49:05
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 April Fool Contest 2022 (順位表) の他の問題:

Problem Statement

Determine whether there exists a sequence $(x_1,\dots,x_N)$ of length $N$, each of whose elements is one of $1,2,3$, that satisfies all of the following $M$ conditions $1,\dots,M$.

Furthermore, if one exists, show one example of such a sequence.

  • Condition $i$: at least one of $x_{p_i} = a_i$ and $x_{q_i} = b_i$ holds.

Input

$N\ M$
$p_1\ q_1\ a_1\ b_1$
...
$p_M\ q_M\ a_M\ b_M$

  • All inputs are integers.
  • $2 \leq N \leq 10^5$
  • $1 \leq M \leq 10^5$
  • $1 \leq p_i < q_i \leq N$
  • $1 \leq a_i\, b_i \leq 3$

Output

If there exists $(x_1,\dots,x_N)$ satisfying all the conditions, output one of them, separated by spaces.

If none exists, output -1.

Sample

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

The conditions are $(x_1=1 \vee x_2=2) \wedge (x_2 = 2 \vee x_3=1)$. For example, $x_1=1,\ x_2=2,\ x_3=3$ satisfies the conditions.

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