# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
396316 |
2021-04-29T18:10:20 Z |
The_Blitz |
Pipes (CEOI15_pipes) |
C++17 |
|
1390 ms |
22520 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[100005];
int g_low[100005];
int g_num[100005];
int P[2][100005];
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]);
}
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 |
112 ms |
3008 KB |
Output is correct |
2 |
Correct |
108 ms |
2884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
198 ms |
3728 KB |
Output is correct |
2 |
Correct |
225 ms |
3192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
5316 KB |
Output is correct |
2 |
Correct |
294 ms |
4892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
459 ms |
10548 KB |
Output is correct |
2 |
Correct |
387 ms |
7068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
682 ms |
11824 KB |
Output is correct |
2 |
Correct |
694 ms |
8996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
930 ms |
13840 KB |
Output is correct |
2 |
Correct |
847 ms |
9008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1112 ms |
13892 KB |
Output is correct |
2 |
Correct |
1060 ms |
9028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1341 ms |
13408 KB |
Output is correct |
2 |
Runtime error |
1390 ms |
22520 KB |
Memory limit exceeded |