# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
396317 |
2021-04-29T18:16:07 Z |
The_Blitz |
Pipes (CEOI15_pipes) |
C++17 |
|
1418 ms |
13960 KB |
// Restart
// += O(logn) ; + = O(n)
#include<vector>
#include<iostream>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
vector<int> G[100001];
int g_low[100001];
int g_num[100001];
int P[2][100001];
int n;
int cont = 1;
void dsu(int z){
for(int i=1; i<=n;i++){
P[z][i] = i;
}
}
int dsu_find(int z, int x){
if(x==P[z][x]) return x;
P[z][x] = dsu_find(z,P[z][x]);
return P[z][x];
}
bool dsu_uni(int z, int a , int b){
int x = dsu_find(z,a);
int y = dsu_find(z,b);
if(x==y) return false;
P[z][y] = x;
G[a].push_back(b);
G[b].push_back(a);
return true;
}
void dfs(int x ,int p = -1){ // p: parent
g_low[x]=g_num[x]=cont++; // low:component ; num:visit order
for(int v : G[x]){
if(v == p) continue;
if(g_num[v]==-1){
dfs(v,x);
if(g_low[v] > g_num[x] && dsu_find(1,v) != dsu_find(1,x)){
cout<< x << " " << v << "\n";
}
g_low[x]=min(g_low[x],g_low[v]);
}
else g_low[x]=min(g_low[x],g_num[v]);
}
}
void go(){
int m;
cin>>n>>m;
for(int i=1;i<=n;i++){
g_low[i] = -1; g_num[i] = -1;
P[0][i] = i; P[1][i] = i;
}
for(int i=1;i<=m;i++){
int x,y; cin>>x>>y;
if(!dsu_uni(0,x,y)){
dsu_uni(1,x,y);
}
}
for(int i=1;i<=n;i++){
if(g_num[i] == -1) dfs(i);
}
}
int main() {
fastio;
go();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3148 KB |
Output is correct |
2 |
Correct |
6 ms |
2892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
3004 KB |
Output is correct |
2 |
Correct |
109 ms |
2868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
3712 KB |
Output is correct |
2 |
Correct |
259 ms |
3188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
327 ms |
5272 KB |
Output is correct |
2 |
Correct |
293 ms |
4888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
477 ms |
10552 KB |
Output is correct |
2 |
Correct |
400 ms |
7084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
710 ms |
11776 KB |
Output is correct |
2 |
Correct |
709 ms |
8916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1020 ms |
13960 KB |
Output is correct |
2 |
Correct |
872 ms |
9008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1152 ms |
13848 KB |
Output is correct |
2 |
Correct |
1072 ms |
9028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1375 ms |
13300 KB |
Output is correct |
2 |
Correct |
1418 ms |
10568 KB |
Output is correct |