# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
103636 | 2019-04-01T15:55:27 Z | zubec | 철인 이종 경기 (APIO18_duathlon) | C++14 | 1000 ms | 1049600 KB |
#include <bits/stdc++.h> using namespace std; typedef 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]; ans += cursum*sz[to]*2; for (int j = 0; j < g[v].size(); j++){ int toto = g[v][j]; if (toto == to || toto == p) continue; ans += sz[toto]*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; } /** 4 3 1 2 2 3 3 4 5 4 1 2 3 4 4 5 4 1 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 1049600 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 1049600 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 215660 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 5 ms | 2688 KB | Output is correct |
4 | Correct | 6 ms | 2816 KB | Output is correct |
5 | Correct | 5 ms | 2688 KB | Output is correct |
6 | Correct | 5 ms | 2816 KB | Output is correct |
7 | Correct | 0 ms | 2688 KB | Output is correct |
8 | Correct | 5 ms | 2688 KB | Output is correct |
9 | Correct | 5 ms | 2816 KB | Output is correct |
10 | Incorrect | 5 ms | 2816 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 6664 KB | Output is correct |
2 | Correct | 79 ms | 6776 KB | Output is correct |
3 | Correct | 78 ms | 6776 KB | Output is correct |
4 | Correct | 90 ms | 6648 KB | Output is correct |
5 | Correct | 89 ms | 6776 KB | Output is correct |
6 | Correct | 113 ms | 10024 KB | Output is correct |
7 | Correct | 101 ms | 8824 KB | Output is correct |
8 | Correct | 123 ms | 8340 KB | Output is correct |
9 | Correct | 99 ms | 7772 KB | Output is correct |
10 | Incorrect | 94 ms | 6776 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2688 KB | Output is correct |
2 | Correct | 5 ms | 2688 KB | Output is correct |
3 | Execution timed out | 1099 ms | 1049600 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 6800 KB | Output is correct |
2 | Correct | 101 ms | 6592 KB | Output is correct |
3 | Execution timed out | 1159 ms | 860024 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 1049600 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 1049600 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |