# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205797 | 2020-03-01T00:38:20 Z | Mamnoon_Siam | Pipes (CEOI15_pipes) | C++17 | 2041 ms | 62324 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; const int N = 1e5 + 5; int n, m; struct dsu { int par[N]; dsu() { memset(par, 0, sizeof par); iota(par, par + N, 0); } int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); } int unite(int u, int v) { u = find(u), v = find(v); if(u == v) return 0; par[u] = v; return 1; } } ds1, ds2; int low[N], in[N], tym = 0; vector<int> g[N]; void dfs(int u, int dad = 0) { in[u] = low[u] = ++tym; for(int v : g[u]) if(v != dad) { if(in[v]) { low[u] = min(low[u], in[v]); } else { dfs(v, u); low[u] = min(low[u], low[v]); if(low[v] > in[u]) { printf("%d %d\n", u, v); } } } } int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &m); for(int i = 0; i < m; i++) { int u, v; scanf("%d %d", &u, &v); if(ds1.unite(u, v) or ds2.unite(u, v)) { g[u].emplace_back(v); g[v].emplace_back(u); } } for(int i = 1; i <= n; i++) { if(!in[i]) { dfs(i); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3448 KB | Output is correct |
2 | Incorrect | 7 ms | 3448 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 3960 KB | Output is correct |
2 | Incorrect | 14 ms | 3768 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 163 ms | 4728 KB | Output is correct |
2 | Incorrect | 164 ms | 4600 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 277 ms | 5332 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 454 ms | 6648 KB | Output is correct |
2 | Runtime error | 389 ms | 19244 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 626 ms | 10196 KB | Output is correct |
2 | Runtime error | 555 ms | 25592 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 971 ms | 11384 KB | Output is correct |
2 | Runtime error | 945 ms | 42116 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1294 ms | 13092 KB | Output is correct |
2 | Runtime error | 1240 ms | 50568 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1610 ms | 16308 KB | Output is correct |
2 | Runtime error | 1597 ms | 62324 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2041 ms | 28940 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 | Halted | 0 ms | 0 KB | - |