Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define f first
- #define s second
- using namespace std;
- int n, m, B = 0, q, pro[20001], gaa[20001], ff, i;
- vector<pair<int, int>> aaa;
- vector<pair<int, int>> deeed;
- vector<vector<int>> zokeri;
- vector<bool> ystal(20001, 0);
- vector<int> konec;
- void dfs (int xi, int ggvp)
- {
- ystal[xi] = 1;
- pro[xi] = q++;
- gaa[xi] = q++;
- for (i = 0; i < zokeri[xi].size(); i++)
- {
- ff = zokeri[xi][i];
- if (ff == ggvp)
- continue;
- if (ystal[ff])
- gaa[xi] = min(gaa[xi], pro[ff]);
- else
- {
- dfs (ff, xi);
- gaa[xi] = min(gaa[xi], gaa[ff]);
- if (gaa[ff] > pro[xi])
- {
- B++;
- deeed.push_back({xi, ff});
- }
- }
- }
- }
- int main()
- {
- int b, e, j, glhf, niay;
- cin >> n >> m;
- aaa.resize(m);
- zokeri.resize(n);
- for(i = 0; i < m; i++)
- {
- cin >> b >> e;
- zokeri[b - 1].push_back(e - 1);
- zokeri[e - 1].push_back(b - 1);
- aaa[i].f = b - 1;
- aaa[i].s = e - 1;
- }
- for (i = 0; i < n; i++)
- {
- if (!ystal[i])
- dfs (i, -1);
- }
- for(i = 0; i < deeed.size(); i++)
- {
- glhf = 0, niay = 0;
- for (j = 0; j < m; j++)
- {
- if (((deeed[i].f == aaa[j].f) and (deeed[i].s == aaa[j].s)) or ((deeed[i].f == aaa[j].s) and (deeed[i].s == aaa[j].f)))
- {
- glhf++;
- niay = j+1;
- }
- }
- if(glhf == 1)
- konec.push_back(niay);
- else
- B--;
- }
- cout << B << "\n";
- sort(konec.begin(), konec.end());
- for(auto N : konec)
- cout << N << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement