# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244636 | 2020-07-04T13:17:12 Z | tqbfjotld | Pipes (CEOI15_pipes) | C++14 | 81 ms | 65540 KB |
#include <vector> #include <cstdio> using namespace std; #define MAXN 100005 bool isBridge[MAXN]; int p[MAXN]; int sz[MAXN]; int depth[MAXN]; vector<int> adjl[MAXN]; int p2[MAXN]; int rt[MAXN]; void dfs(int node, int parent){ for (int x : adjl[node]){ if (x==parent) continue; depth[x] = depth[node]+1; rt[x] = rt[node]; dfs(x,node); if(p2[x]!=node){ isBridge[x] = isBridge[node]; p2[x] = node; } } } int root(int a){ return p[a]==a?a:p[a]=root(p[a]); } int func(int a, int b){ if (a==b) return a; if (depth[b]<depth[a]) swap(a,b); isBridge[b] = false; int t = func(a,p[b]); p[a] = t; p[b] = t; } int n,e; int main(){ //printf("%d\n",sizeof(isBridge)+sizeof(p)+sizeof(sz)+sizeof(depth)+sizeof(adjl)+sizeof(p2)+sizeof(rt)); scanf("%d%d",&n,&e); for (int x = 1; x<=n; x++){ isBridge[x] = false; p[x] = x; sz[x] = 1; depth[x] = 0; rt[x] = x; } for (int x = 0; x<e; x++){ int a,b; scanf("%d%d",&a,&b); if (rt[a]==rt[b]){ func(a,b); } else{ if (sz[root(b)]>sz[root(a)]) swap(a,b); sz[root(a)] += sz[root(b)]; adjl[b].push_back(a); adjl[a].push_back(b); depth[b] = depth[a]+1; p2[b] = a; p[b] = a; rt[b] = rt[a]; dfs(b,a); isBridge[b] = true; } } for (int x = 1; x<=n; x++){ if (isBridge[x]){ printf("%d %d\n",x,p2[x]); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 53 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 48 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 46 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 50 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 50 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 61 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 65 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 71 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 81 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 77 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |