# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156332 | Akashi | Pipes (CEOI15_pipes) | C++14 | 1801 ms | 14028 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;
struct dsu{
int R, aux, TT[100001];
void init(int n){
for(int i = 1; i <= n ; ++i) TT[i] = i;
}
void unite(int x, int y){TT[x] = y;}
int find(int x){
R = x;
while(R != TT[R]) R = TT[R];
while(x != TT[x]){
aux = TT[x];
TT[x] = R;
x = aux;
}
return R;
}
};
dsu A, B;
int n, m;
int low[100001], h[100001];
bitset <100001> viz;
vector <int> v[100001];
void tarjan(int nod, int papa = 0){
viz[nod] = 1;
int cnt = 0;
for(auto it : v[nod]){
if(papa == it){
++cnt;
continue ;
}
if(!viz[it]){
low[it] = h[nod] + 1; h[it] = h[nod] + 1;
tarjan(it, nod);
low[nod] = min(low[nod], low[it]);
if(low[it] > h[nod]) printf("%d %d\n", it, nod);
}
else low[nod] = min(h[it], low[nod]);
}
if(cnt > 1) low[nod] = min(low[nod], h[nod] - 1);
}
int main()
{
scanf("%d%d", &n, &m);
A.init(n); B.init(n);
int x, y;
while(m--){
scanf("%d%d", &x, &y);
if(A.find(x) != A.find(y)){
v[x].push_back(y);
v[y].push_back(x);
A.unite(A.find(x), A.find(y));
}
else if(B.find(x) != B.find(y)){
v[x].push_back(y);
v[y].push_back(x);
B.unite(B.find(x), B.find(y));
}
}
for(int i = 1; i <= n ; ++i) if(!viz[i]) tarjan(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... |