# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146321 | 2019-08-23T12:58:36 Z | evpipis | Pipes (CEOI15_pipes) | C++ | 1700 ms | 28580 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; const int len = 1e5+3; int n, m, cnt; int par[len], num[len], low[len]; vector<int> adj[len]; vector<ii> vec; struct dsu{ int anc[len], sz[len]; void init(){ for (int i = 1; i <= n; i++) anc[i] = i, sz[i] = 1; } int fin(int i){ if (anc[i] == i) return i; return anc[i] = fin(anc[i]); } void join(int i, int j){ i = fin(i), j = fin(j); if (i == j) return; if (sz[i] > sz[j]) sz[i] += sz[j], anc[j] = i; else sz[j] += sz[i], anc[i] = j; } }; dsu one, two; void dfs(int u){ num[u] = low[u] = cnt++; for (int j = 0; j < adj[u].size(); j++){ int v = adj[u][j]; if (!num[v]){ par[v] = u; dfs(v); if (low[v] > num[u]) printf("%d %d\n", u, v); low[u] = min(low[u], low[v]); } else if (v != par[u]){ low[u] = min(low[u], num[v]); } } } int main(){ scanf("%d %d", &n, &m); one.init(); two.init(); for (int i = 0; i < m; i++){ int a, b; scanf("%d %d", &a, &b); if (one.fin(a) != one.fin(b)){ vec.pb(mp(a, b)); one.join(a, b); } else if (two.fin(a) != two.fin(b)){ vec.pb(mp(a, b)); two.join(a, b); } } for (int i = 0; i < vec.size(); i++){ int a = vec[i].fi, b = vec[i].se; adj[a].pb(b); adj[b].pb(a); } for (int i = 1; i <= n; i++) if (!num[i]) dfs(i); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Incorrect | 4 ms | 2680 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3320 KB | Output is correct |
2 | Incorrect | 9 ms | 3192 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 142 ms | 3448 KB | Output is correct |
2 | Incorrect | 142 ms | 3420 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 245 ms | 5316 KB | Wrong number of edges |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 404 ms | 6880 KB | Output is correct |
2 | Correct | 345 ms | 6828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 544 ms | 12132 KB | Output is correct |
2 | Incorrect | 482 ms | 9700 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 858 ms | 13848 KB | Output is correct |
2 | Incorrect | 836 ms | 11532 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1121 ms | 16160 KB | Output is correct |
2 | Incorrect | 1062 ms | 13524 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1412 ms | 16228 KB | Output is correct |
2 | Incorrect | 1343 ms | 14820 KB | Wrong number of edges |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1700 ms | 15840 KB | Output is correct |
2 | Runtime error | 1651 ms | 28580 KB | Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |