luogu#P7320. 「PMOI-4」可怜的团主
「PMOI-4」可怜的团主
Problem Description
lnlhm is given a simple, undirected, connected graph with vertices and edges. Soon, he gets targeted by ducati and b6e0.
ducati wants to find exactly distinct paths such that every vertex is visited by at least one path.
b6e0 wants to find a vertex set of size exactly such that there is no edge between any pair of vertices in the set.
lnlhm knows that if he does not satisfy someone’s requirement, he will be beaten. So he asks you for help: is there a way to choose edges or vertices so that at most one person beats him?
Input Format
The first line contains two positive integers , representing the number of vertices and the number of edges.
The next lines each contain two vertices , describing an undirected edge.
Output Format
If you want to satisfy ducati’s requirement, output on the first line, and then output paths in the next lines, one path per line. You must ensure that these paths are pairwise distinct (for example, you cannot output both and ). The format of one path is as follows:
-
First output a positive integer , the number of vertices on the path.
-
Then output positive integers, the vertices on the path, separated by spaces. You need to ensure that every pair of adjacent vertices has an edge between them, no vertex is visited at least twice by any single path, and every vertex is visited by at least one path.
If you want to satisfy b6e0’s requirement, output on the first line, and then output vertices on the second line to represent the chosen independent set, separated by spaces.
In particular, if neither requirement can be satisfied, output one line Poor lnlhm!.
6 7
1 2
1 3
2 3
2 5
4 5
5 6
4 6
2
1 4
6 6
1 2
2 3
3 4
4 5
5 6
1 6
1
6 1 2 3 4 5 6
Hint
[Sample Explanation]
For the first sample, we only need to choose the vertex set for b6e0. Note that are also valid.
For the second sample, we only need to choose the path for ducati.
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (20pts): .
- Subtask 2 (20pts): the graph is guaranteed to be a tree.
- Subtask 3 (60pts): no special constraints.
For of the testdata, , , and the given graph is guaranteed to be a simple, undirected, connected graph.
Friendly reminder: the input size is large, so please use a fast input method.
Translated by ChatGPT 5