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

#TimeUsernameProblemLanguageResultExecution timeMemory
393371huukhangTraffic (IOI10_traffic)C++11
100 / 100
1208 ms156788 KiB
// - Only when necessary :d // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #include "traffic.h" #include <bits/stdc++.h> using namespace std; const int inf = 2e9; int sum = 0; int a[1000005]; vector<vector<int>> g; int sz[1000005], congest[1000005]; void dfs(int s, int p) { sz[s] = a[s]; for (auto v : g[s]) { if (v != p) { dfs(v, s); sz[s] += sz[v]; congest[s] = max(congest[s], sz[v]); } } congest[s] = max(congest[s], sum - sz[s]); } int LocateCentre(int n, int p[], int s[], int d[]) { for (int i = 0; i < n; ++i) a[i] = p[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]); } for (int i = 0; i < n; ++i) sum += a[i]; dfs(0, -1); int mn = inf, ans; for (int i = 0; i < n; ++i) { if (mn > congest[i]) { mn = congest[i]; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:50:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |  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...