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

#TimeUsernameProblemLanguageResultExecution timeMemory
253352imeimi2000Traffic (IOI10_traffic)C++17
100 / 100
1283 ms159224 KiB
#include <bits/stdc++.h> using namespace std; static vector<int> edge[1000000]; static int V[1000000], sz[1000000], par[1000000]; static void dfs(int x, int p) { par[x] = p; sz[x] = V[x]; for (int i : edge[x]) { if (i == p) continue; dfs(i, x); sz[x] += sz[i]; } } int LocateCentre(int n, int P[], int S[], int D[]) { for (int i = 0; i < n; ++i) { edge[i].clear(); V[i] = P[i]; } for (int i = 0; i < n - 1; ++i) { edge[S[i]].push_back(D[i]); edge[D[i]].push_back(S[i]); } dfs(0, -1); int ansv = 2e9 + 5, ansi = 0; for (int i = 0; i < n; ++i) { int mx = 0; for (int j : edge[i]) { mx = max(mx, par[i] == j ? sz[0] - sz[i] : sz[j]); } if (mx < ansv) ansv = mx, ansi = i; } return ansi; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...