Submission #400299

#TimeUsernameProblemLanguageResultExecution timeMemory
400299Kenzo_1114Towns (IOI15_towns)C++17
35 / 100
22 ms396 KiB
#include<bits/stdc++.h> #include "towns.h" using namespace std; const int MAXN = 110; const int MAXD = 1e6 + 10; int dist[MAXN][MAXN]; int hubDistance(int N, int sub) { int A = 0, B = 0; for(int i = 1; i < N; i++) { dist[0][i] = dist[i][0] = getDistance(0, i); if(dist[0][i] > dist[0][A]) A = i; } B = A; for(int i = 0; i < N; i++) { if(i != 0 && i != A) dist[A][i] = dist[i][A] = getDistance(A, i); if(dist[A][i] > dist[A][B]) B = i; } if(B != 0) for(int i = 1; i < N; i++) if(i != A) dist[B][i] = dist[i][B] = getDistance(B, i); int d = dist[A][B], R = d, DA = d; for(int i = 0; i < N; i++) { if(i == A || i == B) continue; int da = dist[A][B] + dist[A][i] - dist[i][B]; da /= 2; if(max(da, d - da) <= R) DA = da; R = min(R, max(da, d - da)); } int s[3] = {1, 0, 1}; for(int i = 0; i < N; i++) { if(i == A || i == B) continue; int da = dist[A][B] + dist[A][i] - dist[i][B]; da /= 2; if(da < DA) s[0]++; if(da == DA)s[1]++; if(da > DA) s[2]++; } int mx = max(s[0], max(s[1], s[2])); if(mx > N / 2) R *= -1; return R; }

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...