2022-01-03 11:40:03 +00:00
|
|
|
#include <iostream>
|
2022-10-28 03:03:46 +00:00
|
|
|
#include <algorithm>
|
2022-01-03 11:40:03 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using std::cin;
|
|
|
|
using std::cout;
|
2022-10-28 03:03:46 +00:00
|
|
|
const char endl = '\n';
|
2022-01-03 11:40:03 +00:00
|
|
|
|
2022-10-28 03:03:46 +00:00
|
|
|
const int N = 2e4 + 5;
|
2022-01-03 11:40:03 +00:00
|
|
|
|
2022-10-28 03:03:46 +00:00
|
|
|
int n, m;
|
|
|
|
std::vector<int> g[N];
|
|
|
|
int root, cnt, dfn[N], low[N];
|
2022-01-03 11:40:03 +00:00
|
|
|
bool cut[N];
|
|
|
|
|
|
|
|
void tarjan(int u) {
|
|
|
|
dfn[u] = low[u] = ++cnt;
|
|
|
|
bool flag = false;
|
2022-10-28 03:03:46 +00:00
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
for (int v : g[u]) {
|
|
|
|
if (!dfn[v]) {
|
|
|
|
tarjan(v);
|
|
|
|
low[u] = std::min(low[u], low[v]);
|
|
|
|
if (dfn[u] <= low[v]) {
|
|
|
|
if (u != root || flag) {
|
|
|
|
cut[u] = true;
|
|
|
|
} else {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
low[u] = std::min(low[u], dfn[v]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2022-10-28 03:03:46 +00:00
|
|
|
std::ios::sync_with_stdio(false);
|
|
|
|
cin.tie(nullptr);
|
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
cin >> n >> m;
|
2022-10-28 03:03:46 +00:00
|
|
|
|
|
|
|
for (int i = 1, x, y; i <= m; i++) {
|
2022-01-03 11:40:03 +00:00
|
|
|
cin >> x >> y;
|
2022-10-28 03:03:46 +00:00
|
|
|
|
|
|
|
g[x].emplace_back(y);
|
|
|
|
g[y].emplace_back(x);
|
2022-01-03 11:40:03 +00:00
|
|
|
}
|
2022-10-28 03:03:46 +00:00
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
if (!dfn[i]) {
|
|
|
|
root = i;
|
|
|
|
tarjan(i);
|
|
|
|
}
|
|
|
|
}
|
2022-10-28 03:03:46 +00:00
|
|
|
|
|
|
|
cout << std::count(cut + 1, cut + n + 1, true) << endl;
|
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
if (cut[i]) {
|
2022-10-28 03:03:46 +00:00
|
|
|
cout << i << ' ';
|
2022-01-03 11:40:03 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-28 03:03:46 +00:00
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
cout << endl;
|
2022-10-28 03:03:46 +00:00
|
|
|
|
2022-01-03 11:40:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|