# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106374 | 2019-04-18T04:20:19 Z | Hideo | Duathlon (APIO18_duathlon) | C++14 | 205 ms | 15480 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define mk make_pair #define pb push_back #define fr first #define sc second #define vi vector < int > #define pii pair < int, int > const int N = 2e5 + 7; const int INF = 1e9 + 7; int sz[N]; int n, m; int ans; vi g[N]; int asd; int as[N]; void dfs (int v = 1, int p = 0){ sz[v] = 1; as[v] = asd; for (int to : g[v]){ if (!sz[to]){ dfs(to, v); sz[v] += sz[to]; } } } main(){ cin >> n >> m; for (int i = 1; i <= m; i++){ int a, b; scanf("%lld%lld", &a, &b); g[a].pb(b); g[b].pb(a); } for (int i = 1; i <= n; i++) { if (!sz[i]) { asd = i; dfs(i); ans -= sz[i] * (sz[i] - 1) / 2; } } for (int i = 1; i <= n; i++) { ans += (sz[i] * (sz[as[i]] - sz[i])); } cout << ans * 2; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 121 ms | 15480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5120 KB | Output is correct |
2 | Correct | 8 ms | 5120 KB | Output is correct |
3 | Correct | 7 ms | 5120 KB | Output is correct |
4 | Correct | 7 ms | 5120 KB | Output is correct |
5 | Correct | 7 ms | 5120 KB | Output is correct |
6 | Correct | 7 ms | 5120 KB | Output is correct |
7 | Correct | 9 ms | 5120 KB | Output is correct |
8 | Correct | 7 ms | 5120 KB | Output is correct |
9 | Correct | 7 ms | 5120 KB | Output is correct |
10 | Correct | 7 ms | 5120 KB | Output is correct |
11 | Correct | 7 ms | 5120 KB | Output is correct |
12 | Correct | 7 ms | 5120 KB | Output is correct |
13 | Correct | 8 ms | 4992 KB | Output is correct |
14 | Correct | 6 ms | 5120 KB | Output is correct |
15 | Correct | 7 ms | 5120 KB | Output is correct |
16 | Correct | 6 ms | 5120 KB | Output is correct |
17 | Correct | 8 ms | 5120 KB | Output is correct |
18 | Correct | 7 ms | 5120 KB | Output is correct |
19 | Correct | 8 ms | 5120 KB | Output is correct |
20 | Correct | 7 ms | 5120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 11508 KB | Output is correct |
2 | Correct | 90 ms | 11464 KB | Output is correct |
3 | Correct | 90 ms | 11512 KB | Output is correct |
4 | Correct | 90 ms | 11568 KB | Output is correct |
5 | Correct | 89 ms | 11528 KB | Output is correct |
6 | Correct | 109 ms | 13432 KB | Output is correct |
7 | Correct | 122 ms | 13132 KB | Output is correct |
8 | Correct | 114 ms | 12676 KB | Output is correct |
9 | Correct | 94 ms | 12280 KB | Output is correct |
10 | Correct | 96 ms | 11524 KB | Output is correct |
11 | Correct | 98 ms | 11640 KB | Output is correct |
12 | Correct | 205 ms | 11640 KB | Output is correct |
13 | Correct | 89 ms | 11640 KB | Output is correct |
14 | Correct | 87 ms | 11256 KB | Output is correct |
15 | Correct | 67 ms | 11000 KB | Output is correct |
16 | Correct | 50 ms | 9592 KB | Output is correct |
17 | Correct | 77 ms | 11752 KB | Output is correct |
18 | Correct | 72 ms | 11752 KB | Output is correct |
19 | Correct | 61 ms | 11744 KB | Output is correct |
20 | Correct | 61 ms | 11716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5120 KB | Output is correct |
2 | Correct | 6 ms | 5120 KB | Output is correct |
3 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 91 ms | 11716 KB | Output is correct |
2 | Correct | 83 ms | 11508 KB | Output is correct |
3 | Incorrect | 141 ms | 12152 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |