(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #339152

#TimeUsernameProblemLanguageResultExecution timeMemory
339152Ta180mTraffic (IOI10_traffic)C++17
100 / 100
1333 ms149096 KiB
#include "traffic.h" #include <bits/stdc++.h> #define f first #define s second using namespace std; using ll = long long; using ii = pair<int, int>; constexpr int MX = 1e6+5; int sum, sz[MX]; ii ans(2e9, 0); vector<int> G[MX]; void dfs(int u, int p) { for (int v : G[u]) if (v != p) dfs(v, u), sz[u] += sz[v]; } void solve(int u, int p, int P[]) { int up = sum-P[u], mx = 0; for (int v : G[u]) if (v != p) up -= sz[v], mx = max(sz[v], mx); mx = max(up, mx); if (mx < ans.f) ans = ii(mx, u); for (int v : G[u]) if (v != p) solve(v, u, P); } int LocateCentre(int N, int P[], int S[], int D[]) { for (int i = 0; i < N-1; ++i) G[S[i]].push_back(D[i]), G[D[i]].push_back(S[i]); for (int i = 0; i < N; ++i) sum += P[i], sz[i] = P[i]; dfs(0, -1); solve(0, -1, P); return ans.s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...