# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109988 |
2019-05-08T14:16:04 Z |
someone_aa |
Pipes (CEOI15_pipes) |
C++17 |
|
4172 ms |
13912 KB |
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
vector<int>g[maxn];
int n, m;
int tin[maxn], low[maxn];
class dsu {
public:
int uparent[maxn], usize[maxn];
void init() {
for(int i=0;i<=n;i++) {
uparent[i] = i;
usize[i] = 1;
}
}
int uroot(int x) {
while(x != uparent[x]) {
x = uparent[x];
}
return x;
}
bool connected(int x, int y) {
return uroot(x) == uroot(y);
}
void unite(int x, int y) {
x = uroot(x);
y = uroot(y);
if(usize[x] > usize[y]) {
uparent[y] = x;
usize[x] += usize[y];
}
else {
uparent[x] = y;
usize[y] += usize[x];
}
}
}one, two;
int br;
bool visited[maxn];
void dfs(int node, int p) {
tin[node] = br++;
low[node] = tin[node];
visited[node] = true;
bool parent_edge = false;
for(int i:g[node]) {
if(i == p) {
if(parent_edge) low[node] = min(low[node], tin[i]);
parent_edge = true;
continue;
}
if(visited[i]) {
low[node] = min(low[node], tin[i]);
}
else {
dfs(i, node);
low[node] = min(low[node], low[i]);
if(low[i] > tin[node]) {
cout<<i<<" "<<node<<"\n";
}
}
}
}
int main() {
cin>>n>>m;
int u, v;
one.init();
two.init();
for(int i=0;i<m;i++) {
cin>>u>>v;
if(!one.connected(u, v)) {
one.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
else {
if(two.connected(u, v)) continue;
two.unite(u, v);
g[u].pb(v);
g[v].pb(u);
}
}
for(int i=1;i<=n;i++) {
if(!visited[i]) {
dfs(i, -1);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
4 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
3200 KB |
Output is correct |
2 |
Correct |
11 ms |
2944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
356 ms |
3064 KB |
Output is correct |
2 |
Correct |
304 ms |
3036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
628 ms |
3796 KB |
Output is correct |
2 |
Correct |
665 ms |
3388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
995 ms |
5348 KB |
Output is correct |
2 |
Correct |
776 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1347 ms |
10608 KB |
Output is correct |
2 |
Correct |
1160 ms |
7672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2075 ms |
11692 KB |
Output is correct |
2 |
Correct |
2021 ms |
9232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2925 ms |
13912 KB |
Output is correct |
2 |
Correct |
2502 ms |
9832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3487 ms |
13912 KB |
Output is correct |
2 |
Correct |
3293 ms |
9836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4172 ms |
13372 KB |
Output is correct |
2 |
Correct |
3898 ms |
11016 KB |
Output is correct |