# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125428 | 2019-07-05T09:47:45 Z | eriksuenderhauf | Pipes (CEOI15_pipes) | C++11 | 1689 ms | 20520 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]); } 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 | 141 ms | 3604 KB | Output is correct |
2 | Incorrect | 148 ms | 3576 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 242 ms | 4156 KB | Output is correct |
2 | Incorrect | 279 ms | 3704 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 430 ms | 5476 KB | Output is correct |
2 | Incorrect | 340 ms | 5068 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 563 ms | 9760 KB | Output is correct |
2 | Incorrect | 491 ms | 6848 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 878 ms | 11184 KB | Output is correct |
2 | Incorrect | 807 ms | 8208 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1135 ms | 12284 KB | Output is correct |
2 | Incorrect | 1085 ms | 8604 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1385 ms | 12500 KB | Output is correct |
2 | Incorrect | 1329 ms | 8468 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1689 ms | 11948 KB | Output is correct |
2 | Runtime error | 1591 ms | 20520 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |