Submission #399689

#TimeUsernameProblemLanguageResultExecution timeMemory
399689peuchTowns (IOI15_towns)C++17
25 / 100
26 ms1116 KiB
#include "towns.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 1e6; int dist[3][MAXN]; int hubDistance(int N, int sub) { int p1 = 0, p2 = 0; int maxi = 0; for(int i = 0; i < N; i++){ int aux = getDistance(0, i); if(aux > maxi) p1 = i, maxi = aux; } maxi = 0; for(int i = 0; i < N; i++){ dist[0][i] = getDistance(p1, i); if(dist[0][i] > maxi) maxi = dist[0][i], p2 = i; } for(int i = 0; i < N; i++) dist[1][i] = getDistance(p2, i); int diam = dist[0][p2]; int ans = MAXN; for(int i = 0; i < N; i++){ int x = (diam + dist[0][i] - dist[1][i]) / 2; ans = min(ans, max(x, diam - x)); } return ans; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:9:28: warning: unused parameter 'sub' [-Wunused-parameter]
    9 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
#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...