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

#TimeUsernameProblemLanguageResultExecution timeMemory
385002ritul_kr_singhTraffic (IOI10_traffic)C++17
100 / 100
1111 ms170732 KiB
#include <bits/stdc++.h> // #include "traffic.h" using namespace std; const int MAXN = 1e6; vector<vector<int>> g; int sub[MAXN], m[MAXN]={}, sum = 0; pair<int, int> ans = {(int)1e18, -1}; int dfs0(int u, int par){ for(int v : g[u]) if(v != par){ sub[u] += dfs0(v, u); m[u] = max(m[u], sub[v]); } return sub[u]; } int LocateCentre(int n, int pop[], int S[], int D[]){ for(int i=0; i<n; ++i) sum += (sub[i] = pop[i]); g.resize(n); for(int i=0; i<n-1; ++i){ g[S[i]].push_back(D[i]); g[D[i]].push_back(S[i]); } dfs0(0, 0); for(int u=0; u<n; ++u){ m[u] = max(m[u], sum - sub[u]); ans = min(ans, {m[u], u}); } return ans.second; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...