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

#TimeUsernameProblemLanguageResultExecution timeMemory
336177rqiTraffic (IOI10_traffic)C++14
100 / 100
1184 ms170860 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define pb push_back #define mp make_pair #define f first #define s second const ll INF = 1e18; const int mx = 1000005; vi adj[mx]; ll sub[mx]; ll sum = 0; pair<ll, int> ans = mp(INF, -1); void genSub(int node, int prv = -1){ ll val = 0; for(auto u: adj[node]){ if(u == prv) continue; genSub(u, node); sub[node]+=sub[u]; val = max(val, sub[u]); } val = max(val, sum-sub[node]); ans = min(ans, mp(val, node)); } int LocateCentre(int N, int P[], int S[], int D[]) { for(int i = 0; i < N-1; i++){ adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } for(int i = 0; i < N; i++){ sub[i]+=P[i]; sum+=P[i]; } genSub(0); 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...