Submission #764748

#TimeUsernameProblemLanguageResultExecution timeMemory
764748SanguineChameleonTowns (IOI15_towns)C++17
25 / 100
15 ms980 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; const int maxN = 1e2 + 20; int memo[maxN][maxN]; int dist(int u, int v) { if (memo[u][v] != -1) { return memo[u][v]; } else { return memo[u][v] = memo[v][u] = getDistance(u, v); } } int hubDistance(int N, int sub) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { memo[i][j] = (i == j ? 0 : -1); } } int X = 0; for (int i = 0; i < N; i++) { if (dist(0, i) > dist(0, X)) { X = i; } } int Y = 0; for (int i = 0; i < N; i++) { if (dist(X, i) > dist(X, Y)) { Y = i; } } int res = dist(X, Y); for (int i = 0; i < N; i++) { int extra = (dist(X, i) + dist(Y, i) - dist(X, Y)) / 2; res = min(res, max(dist(X, i) - extra, dist(Y, i) - extra)); } return res; }

Compilation message (stderr)

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