Submission #260889

#TimeUsernameProblemLanguageResultExecution timeMemory
260889wiwihoDuathlon (APIO18_duathlon)C++14
0 / 100
91 ms8952 KiB
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; typedef long long ll; const ll MAX = 2147483647; vector<vector<int>> g; vector<bool> vst; ll sz = 0; void dfs(int now){ vst[now] = true; sz++; for(int i : g[now]){ if(!vst[i]) dfs(i); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; g.resize(n + 1); vst.resize(n + 1); ll ans = 0; for(int i = 0; i < m; i++){ int u, v; cin >> u >> v; g[u].eb(v); g[v].eb(u); } for(int i = 1; i <= n; i++){ if(vst[i]) continue; sz = 0; dfs(i); ans += sz * (sz - 1) * (sz - 2) / 3; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...