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

#TimeUsernameProblemLanguageResultExecution timeMemory
239503AutoratchTraffic (IOI10_traffic)C++14
100 / 100
1184 ms167016 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; int res[N],sum,ans,mn = INT_MAX; vector<int> adj[N]; void dfs(int u,int p) { int each = 0; for(int v : adj[u]) if(v!=p) dfs(v,u),each = max(each,res[v]),res[u]+=res[v]; each = max(each,sum-res[u]); if(each<mn) mn = each,ans = u; } int LocateCentre(int n,int p[],int s[],int d[]) { for(int i = 0;i < n;i++) res[i+1] = p[i],sum+=res[i+1]; for(int i = 0;i < n-1;i++) { s[i]++,d[i]++; adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } dfs(1,0); return ans-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...