# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92501 | 2019-01-03T06:26:33 Z | antimirage | Duathlon (APIO18_duathlon) | C++14 | 67 ms | 9820 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb emplace_back #define all(s) s.begin(), s.end() using namespace std; const int N = 1e5 + 5; int n, m, deg[N], x, y, u[N]; long long cn; vector < vector <int> > g; long long ans; bool fl; void dfs (int v) { cn++; u[v] = 1; for (auto to : g[v]) { if (u[to]) continue; dfs(to); } } main() { cin >> n >> m; g.resize(n + 1); for (int i = 1; i <= m; i++) { scanf("%d%d", &x, &y), deg[x]++, deg[y]++; g[x].pb(y); g[y].pb(x); } for (int i = 1; i <= n; i++) { if (deg[i] > 1) fl = 1; } if (fl){ for (int i = 1; i <= n; i++) { if (u[i]) continue; cn = 0; dfs(i); ans += cn * 1ll * (cn - 1) * (cn - 2); } cout << ans << endl; } else{ assert(0); for (int i = 1; i <= n; i++) { if (u[i]) continue; cn = 0; dfs(i); ans += cn * 1ll * (cn - 1) * (cn - 2) / 3; } cout << ans << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 9700 KB | Output is correct |
2 | Correct | 59 ms | 9820 KB | Output is correct |
3 | Incorrect | 54 ms | 8184 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 6776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 58 ms | 6680 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Halted | 0 ms | 0 KB | - |