# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154979 | 2019-09-25T19:15:30 Z | TadijaSebez | Pipes (CEOI15_pipes) | C++11 | 1760 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N=100050; const int H=2*N; const int M=4*N; struct DSU { int p[N]; DSU(){} int Find(int x){ return !p[x]?x:p[x]=Find(p[x]);} void Union(int x, int y){ p[Find(x)]=Find(y);} bool Same(int x, int y){ return Find(x)==Find(y);} } D1,D2; int ab[H],tsz; vector<int> E[N]; void AddEdge(int x, int y){ tsz++;ab[tsz]=x^y;E[x].pb(tsz);E[y].pb(tsz);} int disc[N],low[N],tid; void DFS(int u, int p) { disc[u]=low[u]=++tid; for(int i:E[u]) if(i!=p) { int v=ab[i]^u; if(!disc[v]) { DFS(v,i); if(low[v]>disc[u]) printf("%i %i\n",u,v); low[u]=min(low[u],low[v]); } else low[u]=min(low[u],disc[v]); } } int main() { int n,m,u,v; scanf("%i %i",&n,&m); for(int i=1;i<=m;i++) { scanf("%i %i",&u,&v); if(!D1.Same(u,v)) { D1.Union(u,v); AddEdge(u,v); } else if(!D2.Same(u,v)) { D2.Union(u,v); AddEdge(u,v); } } for(int i=1;i<=n;i++) if(!disc[i]) DFS(i,-1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 3320 KB | Output is correct |
2 | Correct | 9 ms | 3064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 142 ms | 8548 KB | Output is correct |
2 | Correct | 139 ms | 8312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 247 ms | 13436 KB | Output is correct |
2 | Correct | 286 ms | 14712 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 420 ms | 21436 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 590 ms | 31200 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 906 ms | 44820 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1222 ms | 57668 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1471 ms | 65536 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1760 ms | 65536 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |