# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56327 |
2018-07-11T05:11:08 Z |
admin |
Pipes (CEOI15_pipes) |
C++14 |
|
3691 ms |
13968 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;
int n, m;
int U[2][MX];
vector<int> G[MX];
int find(int t, int x){
return x==U[t][x] ? x : U[t][x]=find(t,U[t][x]);
}
void unite(int t, int x, int y){
if(find(t,x)==find(t,y)) return;
U[t][U[t][y]]=U[t][x];
}
int up[MX], dep[MX], now;
void dfs(int v, int p){
dep[v]=++now; up[v]=dep[v];
bool multi=false;
for(int x:G[v]){
if(x==p){
if(multi) up[v]=min(up[v], dep[p]);
multi=true;
continue;
}
if(dep[x]>0) up[v]=min(up[v], dep[x]);
else{
dfs(x,v);
up[v]=min(up[v], up[x]);
if(up[x]>dep[v]) cout<<v<<' '<<x<<'\n';
}
}
now--;
}
int main(){
cin>>n>>m;
for(int i=1; i<=n; i++) U[0][i]=U[1][i]=i;
for(int i=1; i<=m; i++){
int u, v; cin>>u>>v;
if(find(0,u)==find(0,v)){
if(find(1,u)==find(1,v)) continue;
unite(1,u,v);
}
else unite(0,u,v);
G[u].push_back(v);
G[v].push_back(u);
}
for(int i=1; i<=n; i++)
if(dep[i]==0) 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 |
291 ms |
3024 KB |
Output is correct |
2 |
Correct |
286 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
509 ms |
3700 KB |
Output is correct |
2 |
Correct |
590 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
833 ms |
5400 KB |
Output is correct |
2 |
Correct |
747 ms |
5036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1173 ms |
10576 KB |
Output is correct |
2 |
Correct |
1054 ms |
7108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1806 ms |
11816 KB |
Output is correct |
2 |
Correct |
1808 ms |
8920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2378 ms |
13968 KB |
Output is correct |
2 |
Correct |
2543 ms |
9172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3103 ms |
13904 KB |
Output is correct |
2 |
Correct |
2917 ms |
9048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3691 ms |
13384 KB |
Output is correct |
2 |
Correct |
3519 ms |
10724 KB |
Output is correct |