luogu#P4797. [CEOI 2015] 波将金的路径 (Day1)
[CEOI 2015] 波将金的路径 (Day1)
Problem Description
Translated from CEOI2015 Day1 T1 “Potemkin cycle”.
Brief statement Given an undirected graph with and . Find a simple cycle. Let the vertex set of this cycle be . It must satisfy: , and the subgraph induced by contains only this cycle itself.
Duke Potemkin’s territory can be viewed as an undirected graph. He asks you to find a route whose visited vertices are represented by a sequence , and it must satisfy the following:
-
.
-
All visited vertices are pairwise distinct (i.e., for all , ).
-
For , is directly connected to , and is directly connected to .
-
There are no other edges among the vertices in the sequence (i.e., for all such that and either or , there is no edge between and ).
Input Format
The first line contains two non-negative integers and , representing the number of vertices and the number of roads (edges), respectively.
The next lines each contain two distinct positive integers and , indicating that there is an edge between vertices and .
It is guaranteed that there is at most one edge between any pair of vertices.
Output Format
Output the sequence that satisfies the requirements in the description (if there are multiple solutions, output any one). If there is no solution, output no.
5 6
1 2
1 3
2 3
4 3
5 2
4 5
2 3 4 5
4 5
1 2
2 3
3 4
4 1
1 3
no
Hint
The upper limits of and are shown in the table below:
| Test case group | ||||
|---|---|---|---|---|
| Upper limit of | ||||
| Upper limit of |
Translated by ChatGPT 5