#5033. Many Lamps
Many Lamps
Many Lamps
题目描述
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.
输入格式
The input is given from Standard Input in the following format:
输出格式
If it is impossible to turn exactly lamps on, print .
Otherwise, first print , 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.
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
提示
$0 \leq M \leq \min\left( 2 \times 10^5, \frac{N(N-1)}{2} \right)$ 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 . 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.)
标签: AtCoder|abc345F
来源
AtCoder|abc345F