# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103540 | 2019-03-31T11:21:31 Z | Hideo | Duathlon (APIO18_duathlon) | C++14 | 151 ms | 8760 KB |
#include <bits/stdc++.h> using namespace std; #define ll 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; ll ans; vi g[N]; void dfs (int v = 1, int p = 0){ sz[v] = 1; for (int to : g[v]){ if (to != p){ dfs(to, v); sz[v] += sz[to]; } } } main(){ cin >> n >> m; for (int i = 1; i <= m; i++){ int a, b; cin >> a >> b; g[a].pb(b); g[b].pb(a); } if (m == n - 1){ dfs(); for (int i = 1; i <= n; i++){ ans += sz[i] * (n - sz[i]); } ans -= n - 1; cout << (ll) ans * 2 - ((n * - 1) * (n - 2)); } else { cout << 0; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 151 ms | 8100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 143 ms | 8760 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 117 ms | 8664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |