#P16020. [ICPC 2021 NAC] Special Cycle

[ICPC 2021 NAC] Special Cycle

题目描述

You are given a simple undirected graph with no self-loops or multiple edges. Some of the edges are marked as Special.

Your task is to find a simple cycle where, for each Special edge, that edge either belongs to the cycle or neither of its endpoints touch the cycle. The cycle is not allowed to repeat vertices. Output any solution, or report that none exist.

输入格式

The first line of input contains three integers nn (2n1502 \le n \le 150), mm (1mn(n1)21 \le m \le \frac{n(n-1)}{2}) and kk (1km1 \le k \le m), where nn is the number of nodes in the graph, mm is the number of edges, and kk is the number of edges that are Special. The nodes are numbered 11 through nn.

Each of the next mm lines contains two integers aa and bb (1a<bn1 \le a < b \le n), denoting an undirected edge between nodes aa and bb. All edges are distinct. The first kk edges are the Special edges.

输出格式

Output an integer denoting the length of the found cycle on one line. On subsequent lines, output the vertices of the cycle in order around the cycle, one per line. If no such cycle exists, simply output 1-1.

8 10 3
1 2
4 5
7 8
2 3
3 4
1 4
5 6
6 7
5 8
3 8
8
1
4
5
6
7
8
3
2
4 6 3
1 2
1 3
1 4
2 3
3 4
2 4
-1