# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205798 | Mamnoon_Siam | Pipes (CEOI15_pipes) | C++17 | 101 ms | 14204 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int N = 1e5 + 5;
int n, m;
struct dsu {
int par[N];
dsu() {
memset(par, 0, sizeof par);
iota(par, par + N, 0);
}
int find(int u) {
return u == par[u] ? u : par[u] = find(par[u]);
}
int unite(int u, int v) {
u = find(u), v = find(v);
if(u == v) return 0;
par[u] = v;
return 1;
}
} ds1, ds2;
int low[N], in[N], tym = 0;
vector<int> g[N];
void dfs(int u, int dad = 0) {
in[u] = low[u] = ++tym;
for(int v : g[u]) if(v != dad) {
if(in[v]) {
low[u] = min(low[u], in[v]);
} else {
dfs(v, u);
low[u] = min(low[u], low[v]);
if(low[v] > in[u]) {
printf("%d %d\n", u, v);
}
}
}
}
int main(int argc, char const *argv[])
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
scanf("%d %d", &n, &m);
for(int i = 0; i < m; i++) {
int u, v;
scanf("%d %d", &u, &v);
if(ds1.unite(u, v) or ds2.unite(u, v)) {
g[u].emplace_back(v);
g[v].emplace_back(u);
} else {
assert(false);
}
}
for(int i = 1; i <= n; i++) {
if(!in[i]) {
dfs(i);
}
}
return 0;
}
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... |