#abc366g. G - XOR Neighbors
G - XOR Neighbors
Score : points
问题陈述
给定一个简单的无向图,包含 个顶点和 条边。第 条边双向连接顶点 和 。
确定是否存在一种方法,为这个图的每个顶点写上一个介于 和 (包括两端)之间的整数,以满足以下条件:
- 对于每个度数至少为 的顶点 ,其相邻顶点(不包括 本身)上写的数字的总异或值为 。
什么是异或?两个非负整数 和 的异或,记作 ,定义如下:
- 在 的二进制表示中,位置 的位是 当且仅当在 和 的二进制表示中位置 的位中恰好有一个是 。否则,它是 。
例如,(二进制:)。 一般来说, 个整数 的按位异或定义为 $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$。可以证明,这与 的顺序无关。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a simple undirected graph with vertices and edges. The -th edge connects vertices and bidirectionally.
Determine if there exists a way to write an integer between and , inclusive, on each vertex of this graph so that the following condition is satisfied:
- For every vertex with a degree of at least , the total XOR of the numbers written on its adjacent vertices (excluding itself) is .
What is XOR? The XOR of two non-negative integers and , denoted as , is defined as follows:
- In the binary representation of , the bit at position is if and only if exactly one of the bits at position in the binary representations of and is . Otherwise, it is .
For example, (in binary: ).
In general, the bitwise XOR of integers is defined as $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$. It can be proved that this is independent of the order of .
Constraints
- for .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If there is no way to write integers satisfying the condition, print No
.
Otherwise, let be the integer written on vertex , and print your solution in the following format. If multiple solutions exist, any of them will be accepted.
Yes
Sample Input 1
3 3
1 2
1 3
2 3
Sample Output 1
Yes
4 4 4
Other acceptable solutions include writing or .
Sample Input 2
2 1
1 2
Sample Output 2
No
Sample Input 3
1 0
Sample Output 3
Yes
1
Any integer between and can be written.
Sample Input 4
4 5
1 2
1 3
2 3
2 4
3 4
Sample Output 4
Yes
12 4 4 8