Submission #137857

#TimeUsernameProblemLanguageResultExecution timeMemory
137857Osama_AlkhodairyCircle selection (APIO18_circle_selection)C++17
0 / 100
8 ms5368 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long const int N = 100001; int n, m; vector <int> v[N]; ll ans; int dfs(int node, int pnode){ int ret = 1; for(auto &i : v[node]){ if(i == pnode) continue; int cur = dfs(i, node); ret += cur; cout << cur << endl; ans += 1LL * cur * (n - cur); } return ret; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0 ; i < m ; i++){ int x, y; cin >> x >> y; v[x].push_back(y); v[y].push_back(x); } dfs(1, 0); ans *= 2; ans -= 2LL * n * (n - 1) / 2; cout << ans << endl; }
#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...