# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217939 | 2020-03-31T09:29:07 Z | perveevm | Duathlon (APIO18_duathlon) | C++14 | 81 ms | 12664 KB |
// #pragma comment(linker, "/stack:200000000") // #pragma GCC optimize("Ofast,no-stack-protector") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #ifdef PERVEEVM_LOCAL #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl #else #define debug(x) 238; #endif #define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0) #define NAME "File" using ll = long long; using ld = long double; #ifdef PERVEEVM_LOCAL std::mt19937 rnd(238); #else std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count()); #endif const double PI = atan2(0.0, -1.0); const int INF = 0x3f3f3f3f; const ll LINF = (ll)2e18; const int N = 200100; std::vector<int> g[N]; bool used[N]; int sz = 0; void dfs(int v) { used[v] = true; ++sz; for (auto to : g[v]) { if (!used[to]) { dfs(to); } } } void run() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; ++i) { int from, to; scanf("%d%d", &from, &to); g[from - 1].push_back(to - 1); g[to - 1].push_back(from - 1); } ll ans = 0; for (int i = 0; i < n; ++i) { if (!used[i]) { sz = 0; dfs(i); ans += 1ll * sz * (sz - 1) * (sz - 2) / 3; } } printf("%lld\n", ans); } int main(void) { // freopen(NAME".in", "r", stdin); // freopen(NAME".out", "w", stdout); auto start = std::chrono::high_resolution_clock::now(); run(); auto end = std::chrono::high_resolution_clock::now(); #ifdef PERVEEVM_LOCAL std::cerr << "Execution time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms" << std::endl; #endif return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 81 ms | 12664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 69 ms | 9592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 64 ms | 9592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |