# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
527153 |
2022-02-17T02:52:58 Z |
chicken337 |
Pipes (CEOI15_pipes) |
C++14 |
|
1819 ms |
65540 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int v, e, ID = 0;
int num[MAXN], low[MAXN], par[MAXN];
int p[2][MAXN], r[2][MAXN];
vector<int> adj[MAXN];
int root(int id, int x){
if(p[id][x] == x) return x;
return p[id][x] = root(id, p[id][x]);
}
void connect(int id, int x, int y){
x = root(id, x), y = root(id, y);
if(r[id][x] > r[id][y]) swap(x, y);
p[id][x] = y; r[id][y] ++;
}
bool connected(int id, int x, int y){
x = root(id, x), y = root(id, y);
return x == y;
}
void dfs(int x){
num[x] = low[x] = ID ++;
for(int nxt : adj[x]){
if(num[nxt] == -1){
par[nxt] = x; dfs(nxt);
low[x] = min(low[x], low[nxt]);
if(low[nxt] > num[x])
cout << x+1 << ' ' << nxt+1 << '\n';
} else if(nxt != par[x]){
low[x] = min(low[x], num[nxt]);
}
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> v >> e;
for(int i = 0; i < v; i ++)
p[0][i] = p[1][i] = i,
r[0][i] = r[1][i] = 0,
num[i] = low[i] = par[i] = -1;
for(int i = 0; i < e; i ++){
int a, b; cin >> a >> b;
/*
if(!connected(0, a-1, b-1)){
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
connect(0, a-1, b-1);
} else if(!connected(1, a-1, b-1)){
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
connect(1, a-1, b-1);
}*/
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
}
for(int i = 0; i < v; i ++)
if(num[i] == -1)
dfs(i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2672 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3392 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3148 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
11576 KB |
Output is correct |
2 |
Correct |
118 ms |
11084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
200 ms |
15496 KB |
Output is correct |
2 |
Runtime error |
280 ms |
19556 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
425 ms |
27668 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
606 ms |
34436 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
969 ms |
56496 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1286 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1587 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1819 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |