#abc345f. F - Many Lamps

F - Many Lamps

Score: 550550 points

问题陈述

有一个简单图,有 NN 个顶点,编号为 11NN,以及 MM 条边,编号为 11MM。边 ii 连接顶点 uiu_iviv_i。 每个顶点上都有一盏灯。最初,所有的灯都是关闭的。

确定是否可能通过执行以下操作 00MM 次(包括 MM 次),打开恰好 KK 盏灯。

  • 选择一条边。设 uuvv 是边的端点。切换顶点 uuvv 上的灯的状态。也就是说,如果灯是开着的,就关闭它,反之亦然。

如果可能打开恰好 KK 盏灯,请打印出实现这种状态的操作序列。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is a simple graph with NN vertices numbered 11 to NN and MM edges numbered 11 to MM. Edge ii connects vertices uiu_i and viv_i.
Each vertex has one lamp on it. Initially, all the lamps are off.

Determine whether it is possible to turn exactly KK lamps on by performing the following operation between 00 and MM times, inclusive.

  • Choose one edge. Let uu and vv be the endpoints of the edge. Toggle the states of the lamps on uu and vv. That is, if the lamp is on, turn it off, and vice versa.

If it is possible to turn exactly KK lamps on, print a sequence of operations that achieves this state.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • $0 \leq M \leq \min\left( 2 \times 10^5, \frac{N(N-1)}{2} \right)$
  • 0KN0 \leq K \leq N
  • 1ui<viN1 \leq u_i < v_i \leq N
  • The given graph is simple.
  • All input values are integers.

Input

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

NN MM KK

u1u_1 v1v_1

u2u_2 v2v_2

\vdots

uMu_M vMv_M

Output

If it is impossible to turn exactly KK lamps on, print No.

Otherwise, first print Yes, and then print a sequence of operations in the following format:

XX

e1e_1 e2e_2 \dots eXe_X

Here, XX is the number of operations, and eie_i is the number of the edge chosen in the ii-th operation. These must satisfy the following:

  • 0XM0 \leq X \leq M

  • 1eiM1 \leq e_i \leq M

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 33. Turn on the lamps on vertex 22 and vertex 44.
  • Choose edge 44. Turn on the lamps on vertex 33 and vertex 55.
  • Choose edge 55. Turn on the lamp on vertex 11 and turn off the lamp on vertex 55.

After completing all operations, the lamps on vertices 11, 22, 33, and 44 are on. Therefore, this sequence of operations satisfies the conditions.

Other possible sequences of operations that satisfy the conditions include X=4,(e1,e2,e3,e4)=(3,4,3,1)X = 4, (e_1,e_2,e_3,e_4) = (3,4,3,1). (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