Submission #674202

#TimeUsernameProblemLanguageResultExecution timeMemory
674202Jarif_RahmanDuathlon (APIO18_duathlon)C++17
0 / 100
1124 ms1048576 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int n, m; vector<vector<int>> graph; vector<bool> bl; ll cnt = 0; void dfs(int nd, int ss){ cnt++; bl[nd] = 1; for(int x: graph[nd]) if(x != ss) dfs(x, nd); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; graph.resize(n); bl.resize(n, 0); for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; a--, b--; graph[a].pb(b); graph[b].pb(a); } ll ans = 0; for(int i = 0; i < n; i++) if(!bl[i]){ dfs(i, -1); ans+=(cnt*(cnt-1)*(cnt-2))/3; } cout << ans << "\n"; }
#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...