# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
405479 |
2021-05-16T12:49:24 Z |
saleh |
Duathlon (APIO18_duathlon) |
C++17 |
|
1000 ms |
1048580 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 100 * 1000 + 23;
int n, m, ans;
vector<int> g[MAXN];
bitset<MAXN> mark;
//int ent(int x) { return x * (x - 1); }
int gs(int v, int p) {
int res = 1;
mark[v] = true;
for (auto i : g[v]) if (i != p) res += gs(i, v);
return res;
}
int ds(int v, int p) {
int res = g[v].size();
for (auto i : g[v]) if (i != p) res += ds(i, v);
return res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
g[--u].push_back(--v), g[v].push_back(u);
}
for (int i = 0; i < n; i++) if (!mark[i]) {
int x = gs(i, -1);
int y = ds(i, -1);
if (x * 2 == y) ans += x * (x - 1) * (x - 2);
else for (int i = 0; i < x; i++) ans += i * (x - i - 1) * 2;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
638 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
638 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1106 ms |
479536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
7008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
6772 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
638 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
638 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |