Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #pragma GCC optimize ("O3")
- using namespace std;
- using ll = long long;
- const int MAXN = 3e5 + 1488;
- vector<int> gr[MAXN];
- vector<int> t;
- vector<bool> used(MAXN);
- vector<int> tin(MAXN);
- vector<int> fup(MAXN);
- int timer = 0;
- void DFS(int v, int p = -1) {
- cout << "enter v " << v << endl;
- used[v] = true;
- fup[v] = tin[v] = timer++;
- for (int i = 0; i < gr[v].size(); ++i) {
- int to = gr[v][i];
- if (to == p) {
- continue;
- } else if (used[to]) {
- cout << "used to " << to << endl;
- cout << fup[v] << " " << tin[to] << "\n\n";
- fup[v] = min(fup[v], tin[to]);
- } else {
- DFS(to, v);
- cout << "v = " << v << endl;
- cout << fup[v] << " " << fup[to] << "\n\n";
- fup[v] = min(fup[v], fup[to]);
- if (fup[to] > tin[v]) {
- cout << v << " " << to << endl;
- }
- }
- }
- }
- int main() {
- freopen("a.in", "r", stdin), freopen("a.out", "w", stdout);
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int n, m;
- cin >> n >> m;
- for (int i = 0; i < m; ++i) {
- int a, b;
- cin >> a >> b;
- gr[a].push_back(b);
- gr[b].push_back(a);
- }
- DFS(1);
- cout << endl;
- // for (int i = 1; i <= n; ++i) {
- // cout << "i = " << i << " " << tin[i] << " " << fup[i] << endl;
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement