Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstdio>
- #include <cstdlib>
- #include <fstream>
- #include <cmath>
- #include <algorithm>
- #include <set>
- using namespace std;
- int n, m, timer;
- bool color[200001], ans[200001];
- vector <int> edge[200001];
- int in_t[200001], ans_t[200001];
- void dfs(int cur, int parent) {
- int ch = 0;
- color[cur] = true;
- timer++;
- in_t[cur] = timer;
- ans_t[cur] = timer;
- for (int i = 0; i < edge[cur].size(); i++) {
- int cur_t = edge[cur][i];
- if (cur_t == parent) {
- continue;
- }
- if (!color[cur_t]) {
- dfs(cur_t, cur);
- ans_t[cur] = min(ans_t[cur], ans_t[cur_t]);
- if (ans_t[cur_t] >= in_t[cur]) {
- ans[cur] = true;
- }
- ch++;
- } else {
- ans_t[cur] = min(ans_t[cur], in_t[cur_t]);
- }
- }
- if (parent == -1 && ch == 1) {
- ans[cur] = false;
- }
- }
- int main() {
- freopen ("points.in", "r", stdin);
- freopen ("points.out", "w", stdout);
- cin >> n >> m;
- for (int i = 0; i < m; i++) {
- int b, e;
- cin >> b >> e;
- b--;
- e--;
- edge[b].push_back(e);
- edge[e].push_back(b);
- }
- for (int i = 0; i < m; i++) {
- color[i] = false;
- }
- timer = 0;
- int cnt = 0;
- for (int i = 0; i <= n; i++) {
- if (!color[i]) {
- dfs(i, -1);
- }
- }
- for (int i = 0; i <= n; i++) {
- if (ans[i]) {
- cnt++;
- }
- }
- cout << cnt << endl;
- for (int i = 0; i <= cnt; i++) {
- if (ans[i]) {
- cout << i + 1 << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement