# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
405397 | 2021-05-16T10:41:32 Z | aryan12 | 철인 이종 경기 (APIO18_duathlon) | C++17 | 1000 ms | 1048580 KB |
#include <bits/stdc++.h> using namespace std; #define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 5; vector<int> g[N]; bool vis[N]; int subtree[N], ans = 0; int n, m; void dfs(int node, int par) { subtree[node] = 1; vis[node] = true; for(int i = 0; i < g[node].size(); i++) { if(g[node][i] != par) { dfs(g[node][i], node); subtree[node] += subtree[g[node][i]]; } } //cout << "node = " << node << ", subtree[node] = " << subtree[node] << "\n"; int total = subtree[node] - 1, left = n - 1; for(int i = 0; i < g[node].size(); i++) { if(g[node][i] != par) { left -= subtree[g[node][i]]; ans += (subtree[g[node][i]] * left); } } //cout << "node = " << node << ", ans = " << ans << "\n"; } void Solve() { cin >> n >> m; for(int i = 1; i <= m; i++) { int v, u; cin >> v >> u; g[v].push_back(u); g[u].push_back(v); } for(int i = 1; i <= n; i++) { if(!vis[i]) { dfs(i, -1); } } cout << ans * 2 << "\n"; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--) { Solve(); } } /* 8 7 1 2 2 3 3 4 2 5 5 8 1 6 6 7 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 579 ms | 1048580 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 579 ms | 1048580 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1097 ms | 377740 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2676 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Correct | 3 ms | 2636 KB | Output is correct |
4 | Correct | 3 ms | 2636 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Correct | 3 ms | 2684 KB | Output is correct |
7 | Correct | 3 ms | 2636 KB | Output is correct |
8 | Correct | 3 ms | 2636 KB | Output is correct |
9 | Correct | 3 ms | 2636 KB | Output is correct |
10 | Incorrect | 3 ms | 2636 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 7296 KB | Output is correct |
2 | Correct | 52 ms | 7416 KB | Output is correct |
3 | Correct | 66 ms | 7420 KB | Output is correct |
4 | Correct | 73 ms | 7336 KB | Output is correct |
5 | Correct | 70 ms | 7344 KB | Output is correct |
6 | Correct | 70 ms | 9280 KB | Output is correct |
7 | Correct | 73 ms | 9076 KB | Output is correct |
8 | Correct | 80 ms | 8596 KB | Output is correct |
9 | Correct | 70 ms | 8160 KB | Output is correct |
10 | Incorrect | 66 ms | 7400 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2672 KB | Output is correct |
3 | Runtime error | 817 ms | 1048580 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 7408 KB | Output is correct |
2 | Correct | 57 ms | 7268 KB | Output is correct |
3 | Execution timed out | 1030 ms | 1048580 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 579 ms | 1048580 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 579 ms | 1048580 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |