# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
563680 | mjhmjh1104 | Pipes (CEOI15_pipes) | C++17 | 2059 ms | 65536 KiB |
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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 100003;
int v, e, cntDfs, dfsN[MAX];
vector<int> adj[MAX];
vector<pair<int, int>> r;
int dfs(int x, int prev = -1) {
int res = dfsN[x] = cntDfs++;
for (auto &i: adj[x]) {
if (i == prev) continue;
if (dfsN[i]) res = min(res, dfsN[i]);
else if (!dfsN[i]) {
int t = dfs(i, x);
res = min(res, t);
if (t <= dfsN[x]) continue;
r.push_back({ x, i });
}
}
return res;
}
int main() {
scanf("%d%d", &v, &e);
for (int i = 0; i < e; i++) {
int a, b;
scanf("%d%d", &a, &b);
a--, b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int i = 0; i < v; i++) if (!dfsN[i]) dfs(i);
for (auto &i: r) i = make_pair(min(i.first, i.second), max(i.first, i.second));
sort(r.begin(), r.end());
for (auto &i: r) printf("%d %d\n", i.first + 1, i.second + 1);
}
Compilation message (stderr)
# | 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... |