#abc345f. F - Many Lamps
F - Many Lamps
Score: points
问题陈述
有一个简单图,有 个顶点,编号为 到 ,以及 条边,编号为 到 。边 连接顶点 和 。 每个顶点上都有一盏灯。最初,所有的灯都是关闭的。
确定是否可能通过执行以下操作 到 次(包括 次),打开恰好 盏灯。
- 选择一条边。设 和 是边的端点。切换顶点 和 上的灯的状态。也就是说,如果灯是开着的,就关闭它,反之亦然。
如果可能打开恰好 盏灯,请打印出实现这种状态的操作序列。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There is a simple graph with vertices numbered to and edges numbered to . Edge connects vertices and .
Each vertex has one lamp on it. Initially, all the lamps are off.
Determine whether it is possible to turn exactly lamps on by performing the following operation between and times, inclusive.
- Choose one edge. Let and be the endpoints of the edge. Toggle the states of the lamps on and . That is, if the lamp is on, turn it off, and vice versa.
If it is possible to turn exactly lamps on, print a sequence of operations that achieves this state.
Constraints
- $0 \leq M \leq \min\left( 2 \times 10^5, \frac{N(N-1)}{2} \right)$
- The given graph is simple.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If it is impossible to turn exactly lamps on, print No
.
Otherwise, first print Yes
, and then print a sequence of operations in the following format:
Here, is the number of operations, and is the number of the edge chosen in the -th operation. These must satisfy the following:
If multiple sequences of operations satisfy the conditions, any of them will be considered correct.
Sample Input 1
5 5 4
1 2
1 3
2 4
3 5
1 5
Sample Output 1
Yes
3
3 4 5
If we operate according to the sample output, it will go as follows:
- Choose edge . Turn on the lamps on vertex and vertex .
- Choose edge . Turn on the lamps on vertex and vertex .
- Choose edge . Turn on the lamp on vertex and turn off the lamp on vertex .
After completing all operations, the lamps on vertices , , , and are on. Therefore, this sequence of operations satisfies the conditions.
Other possible sequences of operations that satisfy the conditions include . (It is allowed to choose the same edge more than once.)
Sample Input 2
5 5 5
1 2
1 3
2 4
3 5
1 5
Sample Output 2
No
Sample Input 3
10 10 6
2 5
2 6
3 5
3 8
4 6
4 8
5 9
6 7
6 10
7 9
Sample Output 3
Yes
3
10 9 6
update @ 2024/5/16 17:17:10