#P7317. [COCI 2018/2019 #3] Praktični
[COCI 2018/2019 #3] Praktični
Description
You are given an undirected graph with nodes and edges. Each edge has a weight less than .
A cycle is called a good cycle if the XOR sum of the weights of all edges on the cycle is .
You may perform some operations on the undirected graph. Each operation consists of the following steps:
- Choose an integer .
- Choose a non-empty set of edges.
- XOR onto the weight of every edge in this set.
Make all simple cycles in the undirected graph become good cycles using as few operations as possible. Find the minimum number of operations, and output the corresponding operation parameters.
Input Format
The first line contains positive integers , representing the number of nodes and edges.
Each of the next lines (line ) contains , meaning that the -th edge connects nodes and and has weight . It is guaranteed that the graph is connected and has no multiple edges.
Output Format
The first line output , the minimum number of operations required.
In the next lines, output several integers separated by spaces:
- The first number is the chosen number .
- The second number is , the number of chosen edges.
- Then output numbers (), indicating the indices of the chosen edges. These numbers must be output in increasing order.
All output numbers must be less than or equal to .
4 4
1 2 10
2 3 9
3 4 8
4 1 7
1
12 3 1 2 3
2 1
1 2 3
0
6 8
1 2 6
2 3 1
3 5 6
3 1 5
4 5 0
3 6 0
4 2 8
4 1 1
2
2 2 4 6
15 1 7
Hint
Sample 1 Explanation
The initial and final states of the graph (XOR onto the weights of the first three edges based on the initial state) are shown in the left and right figures below:

Sample 2 Explanation
This undirected graph has no cycles, so the requirement is already satisfied and no modification is needed. Therefore, the minimum number of operations is .
Constraints
For of the testdata, .
For another of the testdata, all input numbers are less than or equal to .
For of the testdata, , , , and .
Notes
The score of this problem follows the original COCI setting, with a full score of .
Translated from COCI2018-2019 CONTEST #3 T5 Praktični.
Translated by ChatGPT 5
京公网安备 11011102002149号