#P1364D. Ehab's Last Corollary
Ehab's Last Corollary
Description
Given a connected undirected graph with vertices and an integer , you have to either:
- either find an independent set that has exactly vertices.
- or find a simple cycle of length at most .
An independent set is a set of vertices such that no two of them are connected by an edge. A simple cycle is a cycle that doesn't contain any vertex twice.
I have a proof that for any input you can always solve at least one of these problems, but it's left as an exercise for the reader.
The first line contains three integers , , and (, ) — the number of vertices and edges in the graph, and the parameter from the statement.
Each of the next lines contains two integers and () that mean there's an edge between vertices and . It's guaranteed that the graph is connected and doesn't contain any self-loops or multiple edges.
If you choose to solve the first problem, then on the first line print , followed by a line containing distinct integers not exceeding , the vertices in the desired independent set.
If you, however, choose to solve the second problem, then on the first line print , followed by a line containing one integer, , representing the length of the found cycle, followed by a line containing distinct integers not exceeding , the vertices in the desired cycle, in the order they appear in the cycle.
Input
The first line contains three integers , , and (, ) — the number of vertices and edges in the graph, and the parameter from the statement.
Each of the next lines contains two integers and () that mean there's an edge between vertices and . It's guaranteed that the graph is connected and doesn't contain any self-loops or multiple edges.
Output
If you choose to solve the first problem, then on the first line print , followed by a line containing distinct integers not exceeding , the vertices in the desired independent set.
If you, however, choose to solve the second problem, then on the first line print , followed by a line containing one integer, , representing the length of the found cycle, followed by a line containing distinct integers not exceeding , the vertices in the desired cycle, in the order they appear in the cycle.
Note
In the first sample:
Notice that printing the independent set is also OK, but printing the cycle isn't, because its length must be at most .
In the second sample:
Notice that printing the independent set or printing the cycle is also OK.
In the third sample:
In the fourth sample: