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

#TimeUsernameProblemLanguageResultExecution timeMemory
431823alexis_1729Traffic (IOI10_traffic)C++14
100 / 100
1306 ms174684 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int maxn=1e6+1; vector<int>vx[maxn]; bool vb[maxn]; int pi[maxn],pp[maxn],nd[maxn];int sf=0; void dfs(int node,int r){ for(int i:vx[node]){ if(i!=r){ dfs(i,node); pi[node]+=pi[i]; pp[node]=max(pp[node],pi[i]); }} pp[node]=max(pp[node],sf-pi[node]-nd[node]); pi[node]+=nd[node]; } int LocateCentre(int n, int p[], int S[], int D[]) { for(int i=0;i<n-1;i++){ vx[S[i]].push_back(D[i]); vx[D[i]].push_back(S[i]); } for(int i=0;i<n;i++){sf+=p[i];nd[i]=p[i];} dfs(0,-1); int sum=INT_MAX,ans=-1; for(int i=0;i<n;i++){ if(pp[i]<sum){ sum=pp[i]; 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...