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

#TimeUsernameProblemLanguageResultExecution timeMemory
37692354skyxenonTraffic (IOI10_traffic)C++11
100 / 100
1167 ms186476 KiB
#include <iostream> #include <vector> #include <numeric> using namespace std; #define ll long long const int maxN = 1e6; vector<int> adj[maxN]; int people[maxN]; int children[maxN]; int total; void DFS(int P[], int src, int par) { ll ret = 0; for (int x : adj[src]) { if (x != par) { DFS(P, x, src); children[src] += children[x]; people[src] = max(people[src], children[x]); } } people[src] = max(people[src], total - children[src] - P[src]); children[src] += P[src]; } int LocateCentre(int N, int P[], int S[], int D[]) { ll minCongestion = 2e9; int ans = -1; total = accumulate(P, P + N, 0); for (int i = 0; i < N - 1; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } DFS(P, 0, -1); for (int i = 0; i < N; i++) { ll congestionHere = people[i]; if (congestionHere < minCongestion) { minCongestion = congestionHere; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'void DFS(int*, int, int)':
traffic.cpp:16:8: warning: unused variable 'ret' [-Wunused-variable]
   16 |     ll ret = 0;
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...