# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
617601 |
2022-08-01T12:22:58 Z |
ollel |
Pipes (CEOI15_pipes) |
C++17 |
|
4344 ms |
65540 KB |
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define rep(i,a,b) for(int i = a; i < b; i++)
int n, m;
vi depth, back_edge;
vvi adj;
vi parent;
vvi children;
vector<pii> ans;
void dfs(int x, int cf) {
parent[x] = cf;
for (auto y : adj[x]) {
if (y == parent[x]) continue;
if (depth[y] != -1) {
back_edge[x] = min(back_edge[x], depth[y]);
continue;
}
children[x].pb(y);
back_edge[y] = depth[y] = depth[x] + 1;
dfs(y, x);
}
}
void dfs2(int x) {
for (auto & y : children[x]) dfs2(y);
for (auto & y : children[x]) back_edge[x] = min(back_edge[x], back_edge[y]);
if (depth[x] != 0) if (back_edge[x] >= depth[x]) ans.pb({x+1, parent[x]+1});
}
int main() {
cin >> n >> m;
adj.resize(n); depth.assign(n,-1); back_edge.assign(n,n);
children.resize(n); parent.assign(n,-1);
rep(i,0,m) {
int a, b;
cin >> a >> b;a--;b--;
adj[a].pb(b);
adj[b].pb(a);
}
rep(i,0,n) {
if (depth[i] != -1) continue;
depth[i] = back_edge[i] = 0;
dfs(i, -1);
dfs2(i);
}
cout << ans.size() << endl;
for (auto [x, y] : ans) {
cout << x << " " << y << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1108 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
343 ms |
14108 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
627 ms |
21864 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1202 ms |
40016 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1842 ms |
52152 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3156 ms |
65540 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3680 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4344 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4043 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |