# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154983 | 2019-09-25T19:24:06 Z | TadijaSebez | Pipes (CEOI15_pipes) | C++11 | 1780 ms | 22680 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; vector<int> E[N]; void AddEdge(int x, int y){ E[x].pb(y);E[y].pb(x);} int disc[N],low[N],par[N],tid; void DFS(int u) { disc[u]=low[u]=++tid; bool was=0; for(int v:E[u]) { if(v==par[u] && !was) { was=1; } else { if(!disc[v]) { par[v]=u; DFS(v); 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); 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 | 9 ms | 3320 KB | Output is correct |
2 | Correct | 10 ms | 3064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 3832 KB | Output is correct |
2 | Correct | 140 ms | 3836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 245 ms | 4344 KB | Output is correct |
2 | Correct | 286 ms | 3964 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 406 ms | 5932 KB | Output is correct |
2 | Correct | 343 ms | 5496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 579 ms | 10228 KB | Output is correct |
2 | Correct | 497 ms | 7304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 890 ms | 11384 KB | Output is correct |
2 | Correct | 835 ms | 8952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1176 ms | 13568 KB | Output is correct |
2 | Correct | 1144 ms | 9364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1476 ms | 14152 KB | Output is correct |
2 | Correct | 1367 ms | 9364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1780 ms | 13068 KB | Output is correct |
2 | Runtime error | 1661 ms | 22680 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |