# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
265419 |
2020-08-14T19:29:42 Z |
DS007 |
Duathlon (APIO18_duathlon) |
C++14 |
|
1000 ms |
1048576 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5, M = 2e5;
vector<int> adj[N];
bool explored[N];
int n, m, dp[N][3], ans;
void dfs(int v, int p = -1) {
//cerr << v << endl;
explored[v] = true;
int s1 = 0, s2 = 0;
dp[v][0] = 1;
for (int i : adj[v]) {
if (i != p){
dfs(i, v);
dp[v][0] += dp[i][0];
dp[v][1] += dp[i][0] + dp[i][1];
dp[v][2] += dp[i][1] * 2;
s2 += dp[i][1];
s1 += dp[i][0];
}
}
for (int i : adj[v]) {
if (i != p) {
s2 -= dp[i][1];
s1 -= dp[i][0];
dp[v][2] += s2 * dp[i][0] * 2;
dp[v][2] += s1 * dp[i][0];
s2 += dp[i][1];
s1 += dp[i][0];
}
}
ans += dp[v][2];
}
int solveTestCase() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 0; i < n; i++) {
if (!explored[i])
dfs(i);
cerr << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
}
cout << ans;
return 0;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solveTestCase();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
588 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
588 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1121 ms |
478784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2816 KB |
Output is correct |
2 |
Correct |
16 ms |
2816 KB |
Output is correct |
3 |
Correct |
15 ms |
2816 KB |
Output is correct |
4 |
Correct |
17 ms |
2816 KB |
Output is correct |
5 |
Correct |
16 ms |
2816 KB |
Output is correct |
6 |
Correct |
16 ms |
2816 KB |
Output is correct |
7 |
Correct |
15 ms |
2816 KB |
Output is correct |
8 |
Correct |
16 ms |
2816 KB |
Output is correct |
9 |
Correct |
15 ms |
2816 KB |
Output is correct |
10 |
Correct |
15 ms |
2816 KB |
Output is correct |
11 |
Correct |
16 ms |
2816 KB |
Output is correct |
12 |
Correct |
16 ms |
2816 KB |
Output is correct |
13 |
Correct |
15 ms |
2816 KB |
Output is correct |
14 |
Correct |
15 ms |
2944 KB |
Output is correct |
15 |
Correct |
15 ms |
2816 KB |
Output is correct |
16 |
Correct |
15 ms |
2816 KB |
Output is correct |
17 |
Correct |
15 ms |
2816 KB |
Output is correct |
18 |
Correct |
15 ms |
2816 KB |
Output is correct |
19 |
Correct |
16 ms |
2816 KB |
Output is correct |
20 |
Correct |
15 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
9816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2816 KB |
Output is correct |
2 |
Correct |
16 ms |
2816 KB |
Output is correct |
3 |
Runtime error |
735 ms |
1048576 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
9944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
588 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
588 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |