Submission #615974

#TimeUsernameProblemLanguageResultExecution timeMemory
615974LucppTowns (IOI15_towns)C++17
25 / 100
17 ms348 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); 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++) if(u!=i) du[i] = getDistance(u, i); int v = int(max_element(du.begin(), du.end())-du.begin()); int dia = du[v]; int maxB = 0, maxC = 0; for(int i = 0; i < n; i++){ int b = (d0[u]+d0[i]-du[i])/2; int c = d0[u]-b; if(b+du[v]-d0[u] <= dia/2) maxB = max(maxB, b); if(c <= dia/2) maxC = max(maxC, c); } int R = min(d0[u]-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...