# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244644 | 2020-07-04T13:27:32 Z | tqbfjotld | Pipes (CEOI15_pipes) | C++14 | 330 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; } p[x] = node; } } int func(int a, int b){ //printf("a: %d, depth: %d\n",a,depth[a]); //printf("b: %d, depth: %d\n",b,depth[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 = 0; 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[rt[b]]>sz[rt[b]]) swap(a,b); sz[rt[a]] += sz[rt[b]]; adjl[b].push_back(a); adjl[a].push_back(b); depth[b] = depth[a]+1; p2[b] = a; p[b] = a; //printf("p[%d] set to %d\n",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 | 49 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 | 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 | 49 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 | 59 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 | 57 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 | 102 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 | 127 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 | 120 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 | 117 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 | 330 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |