Submission #778287

#TimeUsernameProblemLanguageResultExecution timeMemory
778287boris_mihovTowns (IOI15_towns)C++17
25 / 100
16 ms1100 KiB
#include "towns.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> typedef long long llong; const int MAXN = 100000 + 10; const int INF = 1e9; int query(int u, int v) { return getDistance(u - 1, v - 1); } int distA[MAXN]; int distB[MAXN]; int distC[MAXN]; int hubDistance(int n, int sub) { int max = 0; int dist = 0; for (int i = 2 ; i <= n ; ++i) { distA[i] = query(1, i); if (distA[i] > dist) { max = i; dist = distA[i]; } } dist = 0; int end = 0; for (int i = 1 ; i <= n ; ++i) { distB[i] = query(max, i); if (distB[i] > dist) { end = i; dist = distB[i]; } } int diff = INF; for (int i = 1 ; i <= n ; ++i) { distC[i] = query(i, end); diff = std::min(diff, abs(distB[i] - distC[i])); } return (distB[end] + diff) / 2; }

Compilation message (stderr)

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