# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125427 | 2019-07-05T09:47:13 Z | eriksuenderhauf | Pipes (CEOI15_pipes) | C++11 | 1704 ms | 65536 KB |
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define pb push_back using namespace std; const int MAXN = 1e5 + 5; vector<int> adj[MAXN]; int cnt = 1, par[MAXN], par2[MAXN], lo[MAXN]; int qry(int x) { return x == par[x] ? x : par[x] = qry(par[x]); } void join(int u, int v) { u = qry(u), v = qry(v); par[u] = v; } int qry2(int x) { return x == par2[x] ? x : par2[x] = qry2(par2[x]); } void join2(int u, int v) { u = qry2(u), v = qry2(v); par2[u] = v; } void dfs(int u, int p) { par[u] = lo[u] = cnt++; while (!adj[u].empty()) { int v = adj[u].back(); adj[u].pop_back(); if (!par[v]) { dfs(v, u); lo[u] = min(lo[u], lo[v]); if (lo[v] > par[u] && qry2(u) != qry2(v)) printf("%d %d\n", u, v); } else if (v != p) lo[u] = min(lo[u], par[v]); } par[u] = lo[u] = 0; } int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) par[i] = par2[i] = i; for (int i = 0; i < m; i++) { int u, v; scanf("%d %d", &u, &v); if (qry2(u) == qry2(v)) continue; if (qry(u) == qry(v)) { adj[u].pb(v); adj[v].pb(u); join2(u, v); continue; } join(u, v); adj[u].pb(v); adj[v].pb(u); } for (int i = 1; i <= n; i++) par[i] = 0; for (int i = 1; i <= n; i++) if (!par[i]) dfs(i, 0); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2680 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 3192 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 135 ms | 3704 KB | Output is correct |
2 | Incorrect | 132 ms | 3492 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 233 ms | 4216 KB | Output is correct |
2 | Incorrect | 272 ms | 3780 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 386 ms | 5564 KB | Output is correct |
2 | Incorrect | 328 ms | 4972 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 553 ms | 9784 KB | Output is correct |
2 | Incorrect | 481 ms | 6904 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 862 ms | 11544 KB | Output is correct |
2 | Incorrect | 797 ms | 8148 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1123 ms | 12300 KB | Output is correct |
2 | Incorrect | 1056 ms | 8572 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1368 ms | 12532 KB | Output is correct |
2 | Incorrect | 1320 ms | 8568 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1704 ms | 12104 KB | Output is correct |
2 | Runtime error | 1584 ms | 65536 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |