# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103635 | 2019-04-01T15:50:41 Z | zubec | Duathlon (APIO18_duathlon) | C++14 | 1000 ms | 1042908 KB |
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; typedef long double ld; const int N = 100100; int n, m; vector <int> g[N]; ll sz[N]; ll ans = 0; void dfs(int v, int p){ sz[v] = 1; for (int i = 0; i < g[v].size(); i++){ int to = g[v][i]; if (to == p) continue; dfs(to, v); sz[v] += sz[to]; } ll cursum = n-sz[v]; for (int i = 0; i < g[v].size(); i++){ int to = g[v][i]; if (to == p) continue; ans += cursum*sz[to]; cursum += sz[to]; } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); cin >> n >> m; for (int i = 1; i <= m; i++){ int u, v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } dfs(1, 0); cout << ans*2; } /** 4 3 1 2 2 3 3 4 5 4 1 2 3 4 4 5 4 1 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1161 ms | 1042908 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1161 ms | 1042908 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1067 ms | 196832 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2816 KB | Output is correct |
2 | Correct | 4 ms | 2688 KB | Output is correct |
3 | Correct | 5 ms | 2816 KB | Output is correct |
4 | Correct | 5 ms | 2816 KB | Output is correct |
5 | Correct | 6 ms | 2816 KB | Output is correct |
6 | Correct | 5 ms | 2688 KB | Output is correct |
7 | Correct | 5 ms | 2816 KB | Output is correct |
8 | Correct | 5 ms | 2688 KB | Output is correct |
9 | Correct | 5 ms | 2688 KB | Output is correct |
10 | Incorrect | 6 ms | 2816 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 6648 KB | Output is correct |
2 | Correct | 113 ms | 6748 KB | Output is correct |
3 | Correct | 109 ms | 6848 KB | Output is correct |
4 | Correct | 83 ms | 6644 KB | Output is correct |
5 | Correct | 111 ms | 6860 KB | Output is correct |
6 | Correct | 121 ms | 10068 KB | Output is correct |
7 | Correct | 111 ms | 8836 KB | Output is correct |
8 | Correct | 111 ms | 8224 KB | Output is correct |
9 | Correct | 113 ms | 7800 KB | Output is correct |
10 | Incorrect | 119 ms | 6776 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2688 KB | Output is correct |
2 | Correct | 5 ms | 2816 KB | Output is correct |
3 | Execution timed out | 1156 ms | 990240 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 6732 KB | Output is correct |
2 | Correct | 96 ms | 6752 KB | Output is correct |
3 | Execution timed out | 1145 ms | 857016 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1161 ms | 1042908 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1161 ms | 1042908 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |