Submission #764751

#TimeUsernameProblemLanguageResultExecution timeMemory
764751SanguineChameleonTowns (IOI15_towns)C++17
35 / 100
15 ms400 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 R = dist(X, Y); map<int, int> cnt; for (int i = 0; i < N; i++) { int mid = (dist(X, i) + dist(Y, i) - dist(X, Y)) / 2; int left = dist(X, i) - mid; int right = dist(Y, i) - mid; cnt[left]++; R = min(R, max(left, right)); } int pref = 0; int suf = N; for (auto p: cnt) { suf -= p.second; if (max(p.first, dist(X, Y) - p.first) == R && pref <= N / 2 && p.second <= N / 2 && suf <= N / 2) { return R; } pref += p.second; } return -R; }

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