# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959302 | 2024-04-07T23:13:21 Z | Cyber_Wolf | Pipes (CEOI15_pipes) | C++11 | 1012 ms | 48944 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5+5; vector<int> adj[N]; int tin[N], par[N][2], low[N]; int get1(int src) { return par[src][0] = (src == par[src][0] ? src : get1(par[src][0])); } int get2(int src) { return par[src][1] = (src == par[src][1] ? src : get2(par[src][1])); } int n, m, tmp; void dfs(int src, int pa = -1) { bool a = 0; tin[src] = low[src] = ++tmp; for(auto it : adj[src]) { if(it == pa && !a) { a = 1; continue; } if(tin[it]) { low[src] = min(low[src], tin[it]); continue; } dfs(it, src); low[src] = min(low[src], low[it]); if(low[it] > tin[src]) { printf("%d %d\n", src, it); } } return ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) par[i][0] = par[i][1] = i; int u, v, pU, pV; while(m--) { scanf("%d%d", &u, &v); pU = get1(u), pV = get1(v); if(pU != pV) { par[pU][0] = pV; adj[u].push_back(v), adj[v].push_back(u); } else{ pU = get2(u), pV = get2(v); if(pU != pV) { par[pU][1] = pV; adj[u].push_back(v), adj[v].push_back(u); } } } for(int i = 1; i <= n; i++) { if(!tin[i]) dfs(i); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4188 KB | Output is correct |
2 | Correct | 1 ms | 4188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4952 KB | Output is correct |
2 | Correct | 5 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 90 ms | 7764 KB | Output is correct |
2 | Correct | 87 ms | 7492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 151 ms | 10700 KB | Output is correct |
2 | Correct | 180 ms | 10832 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 249 ms | 15316 KB | Output is correct |
2 | Correct | 201 ms | 13588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 334 ms | 22072 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 513 ms | 29348 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 644 ms | 37056 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 823 ms | 42356 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1012 ms | 48944 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |