#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair < ll, ll >;
const ll N = 1e5 + 2;
ll tin[N], timer = 0, used[N], low[N];
vector < ll > adj[N];
vector < pll > edges;
void euler_tour(ll node, ll par) {
tin[node] = timer;
low[node] = timer;
used[node] = 1;
timer ++;
bool parent_found = false;
for ( ll nxt : adj[node]) {
if ( nxt == par && parent_found == false) {
parent_found = true;
continue;
}
if ( used[nxt] == 1) {
low[node] = min(low[node], tin[nxt]);
continue;
}
euler_tour(nxt, node);
low[node] = min(low[node], low[nxt]);
if ( low[nxt] > tin[node]) {
cout << node << " " << nxt << endl;
}
}
}
int main() {
ll n, m, r, x, y, i, j, ans, t;
cin >> n >> m;
for (i = 1; i <= m; i ++) {
cin >> x >> y;
adj[x].push_back(y);
adj[y].push_back(x);
}
for (i = 1; i <= n; i ++) {
if ( used[i] == 0) euler_tour(i, -1);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |