Submission #127337

#TimeUsernameProblemLanguageResultExecution timeMemory
127337kingfran1907Towns (IOI15_towns)C++14
25 / 100
68 ms4988 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; const int maxn = 120; const int maxm = 1e6+10; const int inf = 0x3f3f3f3f; int qs[maxn][maxn]; int sol[maxm]; int query(int a, int b) { if (a > b) swap(a, b); if (qs[a][b] == -1) qs[a][b] = getDistance(a, b); return qs[a][b]; } int hubDistance(int n, int sub) { memset(qs, -1, sizeof qs); memset(sol, inf, sizeof sol); for (int i = 0; i < n; i++) qs[i][i] = 0; int a = 0, b = 0; for (int i = 0; i < n; i++) if (query(0, a) < query(0, i)) a = i; for (int i = 0; i < n; i++) if (query(a, i) > query(a, b)) b = i; int R = inf; for (int i = 0; i < n; i++) { int cd = (query(a, i) + query(b, i) - query(a, b)) / 2; int ad = query(a, i) - cd; int bd = query(b, i) - cd; sol[ad] = max({cd, ad, bd}); } for (int i = 0; i < maxm; i++) R = min(R, sol[i]); return R; }

Compilation message (stderr)

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