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;
const int MAXN = 100005;
int depth[MAXN] = {0};
int low[MAXN] = {0};
vector<int> AL[MAXN];
void AP(int i, int d, int pa) {
depth[i] = d; low[i] = d;
int paedges = 0;
for (int ch : AL[i]) {
if (ch==pa) {
paedges++;
continue;
}
if (depth[ch] > -1) {
low[i] = min(low[i], depth[ch]);
} else {
AP(ch, d+1, i);
low[i] = min(low[i], low[ch]);
}
}
if (pa==-1) return;
if (low[i] > depth[pa] && paedges == 1) {
cout << i+1 << " " << pa+1 << "\n";
}
}
int main() {
int N, M, a, b; cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> a >> b; a--;b--;
AL[a].push_back(b); AL[b].push_back(a);
}
for (int i = 0; i < N; i++) {
depth[i] = -1;
}
for (int i = 0; i < N; i++) {
if (depth[i] == -1) AP(i,0,-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... |