제출 #1127183

#제출 시각아이디문제언어결과실행 시간메모리
1127183czauderna철인 이종 경기 (APIO18_duathlon)C++20
0 / 100
1131 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]){ if(w==p) continue; tmp+=siz[w]*(siz[v]-siz[w]); } out+=tmp; 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...