제출 #745174

#제출 시각아이디문제언어결과실행 시간메모리
745174Desh03Traffic (IOI10_traffic)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g; vector<int> sz, a; int ans = INT_MAX; void dfs(int u, int p) { sz[u] = a[u]; for (int v : g[u]) if (v ^ p) dfs(v, u), sz[u] += sz[v]; } void solve(int u, int p) { int x = sz[0] - sz[u]; for (int v : g[u]) if (v ^ p) solve(v, u), x = max(x, sz[v]); ans = min(ans, x); } int LocateCentre(int n, int p[], int s[], int d[]) { g.resize(n), sz.resize(n), a.resize(n); for (int i = 0; i < n; i++) a[i] = p[i]; for (int i = 0; i < n - 1; i++) { g[s[i]].push_back(d[i]); g[d[i]].push_back(s[i]); } dfs(0, 0); solve(0, 0); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...