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

#TimeUsernameProblemLanguageResultExecution timeMemory
252841SamAndTraffic (IOI10_traffic)C++17
100 / 100
1234 ms166904 KiB
#include "traffic.h" #include <algorithm> #include <vector> #include <cmath> #include <queue> using namespace std; const int N = 1000003,INF=2000000001; int n; vector<pair<int,int> > a[N]; int b[N]; int sum, ans = INF, ansi; int dfs(int x, int p) { int res=0; int yans=0; for (int i = 0; i < a[x].size(); ++i) { int h = a[x][i].first; if (h == p) continue; a[x][i].second = dfs(h,x); res += a[x][i].second; yans = max(yans, a[x][i].second); } yans = max(yans, sum - res - b[x]); if (yans < ans) { ans = yans; ansi = x; } return res + b[x]; } int LocateCentre(int N, int pp[], int S[], int D[]) { n = N; for (int i = 0; i < n; ++i) { b[i] = pp[i]; sum += b[i]; } for (int i = 0; i < n - 1; ++i) { a[S[i]].push_back(make_pair(D[i],0)); a[D[i]].push_back(make_pair(S[i],0)); } dfs(0,-1); return ansi; }

Compilation message (stderr)

traffic.cpp: In function 'int dfs(int, int)':
traffic.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a[x].size(); ++i)
                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...