创建于 2026/07/18 · 更新于 2026/07/18
You are given a connected, simple, undirected graph with vertices and edges.
We call a simple cycle safely removable if deleting all of its edges keeps the graph connected.
You should complete exactly one of the two tasks below (you choose which one), and you do not need to do both. It can be proved that at least one of the two tasks is always achievable.
1. 3-color the graph: give each vertex a color in so that the two endpoints of every edge get different colors.
2. Find a safely removable odd cycle: output a simple cycle of odd length that is safely removable.
The first line contains and . Each of the next lines contains two integers and (, ), meaning there is an edge between vertices and . The graph is connected and has no self-loops or repeated edges.
, .
For task 1, print , then a line of integers ().
For task 2, print , then a line with the odd cycle length followed by the cycle vertices in order.
Any valid answer is accepted by a special judge.
3 3
1 2
3 2
1 3
1
1 2 3
4 6
4 2
4 1
2 3
3 1
4 3
1 2
2
3 3 4 2
6 5
3 6
2 6
4 1
6 1
5 6
1
1 1 1 2 1 2