#5033. Many Lamps

0

Many Lamps

Many Lamps

题目描述

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.

输入格式

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

输出格式

If it is impossible to turn exactly KK lamps on, print NoNo.
Otherwise, first print YesYes, 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:

0≤X≤M0 \leq X \leq M 1≤ei≤M1 \leq e_i \leq M

If multiple sequences of operations satisfy the conditions, any of them will be considered correct.

5 5 4
1 2
1 3
2 4
3 5
1 5
Yes
3
3 4 5
5 5 5
1 2
1 3
2 4
3 5
1 5
No
10 10 6
2 5
2 6
3 5
3 8
4 6
4 8
5 9
6 7
6 10
7 9
Yes
3
10 9 6

提示

1≤N≤2×1051 \leq N \leq 2 \times 10^5 $0 \leq M \leq \min\left( 2 \times 10^5, \frac{N(N-1)}{2} \right)$ 0≤K≤N0 \leq K \leq N 1 \leq u_i < v_i \leq N The given graph is simple. All input values are integers.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.)

标签: AtCoder|abc345F

来源

AtCoder|abc345F