(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 #414507

#TimeUsernameProblemLanguageResultExecution timeMemory
414507dxz05Traffic (IOI10_traffic)C++14
100 / 100
1110 ms166764 KiB
#include "traffic.h" #include <vector> using namespace std; const int MAXN = 1e6 + 3e2; vector<int> g[MAXN]; int cnt[MAXN]; void dfs(int v, int p){ for (int u : g[v]){ if (u != p){ dfs(u, v); cnt[v] += cnt[u]; } } } int LocateCentre(int N, int pp[], int S[], int D[]) { for (int i = 0; i < N; i++) cnt[i] = pp[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); int mn = 2e9 + 5, ans = 0; for (int i = 0; i < N; i++){ int cur = cnt[0] - cnt[i]; for (int j : g[i]){ if (cnt[j] < cnt[i]) cur = max(cur, cnt[j]); } if (cur < mn) mn = cur, ans = i; } 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...