Submission #615936

#TimeUsernameProblemLanguageResultExecution timeMemory
615936LucppTowns (IOI15_towns)C++17
25 / 100
15 ms1092 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; int hubDistance(int n, int sub) { sub--; // suppress unused warning vector<int> d0(n), du(n), dv(n); for(int i = 1; i < n; i++) d0[i] = getDistance(0, i); int u = int(max_element(d0.begin(), d0.end())-d0.begin()); for(int i = 0; i < n; i++) du[i] = getDistance(u, i); int v = int(max_element(du.begin(), du.end())-du.begin()); for(int i = 0; i < n; i++) dv[i] = getDistance(v, i); int dia = du[v]; int maxB = 0, maxC = 0; for(int i = 0; i < n; i++){ int b = (dia+du[i]-dv[i])/2; int c = dia-b; if(b <= dia/2) maxB = max(maxB, b); if(c <= dia/2) maxC = max(maxC, c); } int R = min(dia-maxB, dia-maxC); return R; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...