Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define pb(x) push_back(x)
- using namespace std;
- const int N = 100005;
- int n,m,par[N],cnt=0;
- vector<int> a[N];
- vector<int> res;
- int num[N],low[N];
- void dfs(int u)
- {
- int x = (par[u] != -1);
- num[u]=low[u]=++cnt;
- for(int &v : a[u])
- {
- if (v == par[u]) continue;
- if (par[v]) low[u] = min(low[u],num[v]);
- else
- {
- par[v]=u;
- dfs(v);
- low[u]=min(low[u],low[v]);
- if (low[v] >= num[u]) ++x;
- }
- }
- if (x >= 2) res.pb(u);
- }
- signed main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);cout.tie(0);
- freopen("cnode.inp","r",stdin);
- freopen("cnode.out","w",stdout);
- cin >> n >> m;
- for(int i=1; i<=m; ++i)
- {
- int u,v;
- cin >> u >> v;
- a[u].pb(v);
- a[v].pb(u);
- }
- for(int i=1; i<=n; ++i)
- {
- if (!par[i])
- {
- par[i]=-1;
- dfs(i);
- }
- }
- cout << res.size() << endl;
- for(int &i : res) cout << i << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement