P23379 [AtCoder] [ABC366G] XOR Neighbors
提高+
题目描述

Problem Description

You are given a simple undirected graph with $ N $ vertices and $ M $ edges. The $ i $th edge connects vertices $ u_i $ and $ v_i $ bidirectionally.

Determine if there exists a way to write integers between $ 1 $ and $ 2^{60} $ (exclusive) on each vertex of the graph such that the following condition is satisfied, and if so, construct one such way.

  • For every vertex $ v $ with degree $ 1 $ or more, the total XOR of the numbers written on the adjacent vertices (excluding $ v $ itself) is $ 0 $.

The XOR of non-negative integers $ A $ and $ B $, denoted as $A \oplus B$, is defined as follows: - When $A \oplus B$ is written in binary, the digit in the $ 2^k $ place ($k \geq 0$) is $ 1 $ if exactly one of the digits in the $ 2^k $ place of $ A $ and $ B $ in binary is $ 1 $, otherwise it is $ 0 $.

For example, $3 \oplus 5 = 6$ (in binary: $011 \oplus 101 = 110$). Generally, the XOR of $ k $ integers $p_1, \dots, p_k$ is defined as $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$, and it can be proven that this does not depend on the order of $p_1, \dots, p_k$.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ u_1 $ $ v_1 $ $ u_2 $ $ v_2 $ $\vdots$ $ u_M $ $ v_M $

Output Format

If there is no way to write integers that satisfies the condition, output No.

If there is a way, let $ X_v $ be the integer written on vertex $ v $, and output in the following format. If there are multiple answers, any one of them is acceptable.

Yes $ X_1 $ $ X_2 $ $\dots$ $ X_N $

Sample Input and Output

Sample Input #1

3 3
1 2
1 3
2 3

Sample Output #1

Yes
4 4 4

Sample Input #2

2 1
1 2

Sample Output #2

No

Sample Input #3

1 0

Sample Output #3

Yes
1

Sample Input #4

4 5
1 2
1 3
2 3
2 4
3 4

Sample Output #4

Yes
12 4 4 8

Notes/Hints

Constraints

  • $1 \leq N \leq 60$
  • $0 \leq M \leq N(N-1)/2$
  • $1 \leq u_i < v_i \leq N$
  • $(u_i, v_i) \neq (u_j, v_j)$ if $i \neq j$
  • All inputs are integers

Sample Explanation 1

Other correct answers include writing $ (2, 2, 2) $ or $ (3, 3, 3) $.

Sample Explanation 3

Any integer between $ 1 $ and $ 2^{60} $ (exclusive) written on the vertex is a correct answer.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 1 2 1 3 2 3
样例输出
Yes 4 4 4