P1793 Running
Description
New cows arrived at the unit. CG requires them to go for a morning run every day, from Farm $A$ to Farm $B$. Between Farm $A$ and Farm $B$ there are $n-2$ intersections, which are numbered: Farm $A$ is number $1$, Farm $B$ is number $n$, and the intersections are numbered $2,3,4,\cdots,n-1$. There are many routes from Farm $A$ to Farm $B$. CG notices that some intersections are must-pass, meaning every route goes through them. CG wants to record them, so CG can go to such an intersection first to check whether the new cows are slacking. Your task is to find all must-pass intersections.
Input Format
The first line contains two integers $n\ (3 \le n \le 2000)$ and $e\ (1 \le e \le 8000)$ separated by a space.
From line $2$ to line $e+1$, each line contains two integers $p$ and $q$ separated by a space, indicating that there is a direct path between intersection $p$ and $q$.
The input guarantees that must-pass intersections exist, and every intersection is connected to both Farm $A$ and Farm $B$.
Output Format
The first line contains an integer $m$, the number of must-pass intersections.
On the second line, output the indices of all must-pass intersections in increasing order, with a single space between every two numbers.
Explanation/Hint
Translated by ChatGPT 5