Submission #1127181

#TimeUsernameProblemLanguageResultExecution timeMemory
1127181czaudernaDuathlon (APIO18_duathlon)C++20
0 / 100
1130 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const int N = 1e5+3; vector<int> grf[N], tree[N]; int pre[N], low[N], cnt; ll siz[N], out; bool odw[N]; void dfs(int v, int p){ odw[v]=1; for(auto w:grf[v]){ if(w==p) continue; dfs(w, v); siz[v]+=siz[w]; } ll tmp=0; for(auto w:grf[v]) tmp+=siz[w]*(siz[v]-siz[w]); out+=tmp/2; siz[v]++; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for(int i=0; i<m; i++){ int a, b; cin >> a >> b; grf[a].pb(b); grf[b].pb(a); } for(int i=1; i<=n; i++){ if(odw[i]) continue; dfs(i, i); } cout << out << '\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...