#P10731. [NOISG 2023 Qualification] Network
[NOISG 2023 Qualification] Network
Problem Description
Duck Rui Yuan has servers and bidirectional data cables. The -th cable connects and in both directions. It is guaranteed that for all , you can reach server from server through the cables, and vice versa.
Rui Yuan also has applications running. The -th application runs on two servers, and .
Initially, all servers are running.
The -th application can run if both of the following conditions hold:
-
Both and are running servers.
-
Between and , there is a connection through data cables and running servers.
Rui Yuan wants you to find the minimum number of servers that must be stopped so that all applications stop running.
Input Format
The first line contains two integers .
The next lines each contain two integers .
The next lines each contain two integers .
Output Format
The first line contains an integer , the minimum number of servers that must be stopped.
The next line contains integers, the indices of the servers to be stopped. All integers must be distinct. You may output them in any order.
9 4
1 2
2 3
2 6
3 4
4 5
4 7
6 9
7 8
6 2
5 3
4 8
5 9
2
4 2
6 5
1 2
2 3
4 1
3 5
4 6
1 1
2 2
3 3
2 2
4 4
4
3 2 4 1
8 3
1 2
2 3
3 4
4 5
5 6
6 7
7 8
3 5
8 5
4 4
2
4 6
6 2
1 2
1 3
1 4
1 5
1 6
2 2
5 6
2
2 1
Hint
Constraints
| Score | Special Property | |
|---|---|---|
| Sample | ||
| None | ||
For of the testdata, $1 \le n,m \le 200000, 1 \le u_i,v_i \le n, u_i\not = v_i, 1 \le a_j,b_j\le n$.
Translated by ChatGPT 5