This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N,M, depth[100005], low[100005], p[100005];
vector<int> lst[100005];
bitset<100005> visited;
void dfs (int u, int d) {
visited[u] = 1, depth[u] = d, low[u] = d;
int num = 0;
for (int v: lst[u]) {
if (!visited[v]) {
p[v] = u, num++;
dfs(v,d+1);
if (low[v] > depth[u]) cout << u+1 << ' ' << v+1 << '\n';
low[u] = min(low[u],low[v]);
}
else if (v != p[u])
low[u] = min(low[u],depth[v]);
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> M;
for (int i = 0; i < M; ++i) {
int u,v; cin>> u >> v; u--, v--;
lst[u].push_back(v), lst[v].push_back(u);
}
for (int i = 0; i < N; ++i) if (!visited[i]) dfs(i,0);
return 0;
}
# | 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... |