Submission #129539

#TimeUsernameProblemLanguageResultExecution timeMemory
129539johuthaTowns (IOI15_towns)C++14
25 / 100
21 ms1016 KiB
#include "towns.h" #include <vector> #include <iostream> #include <algorithm> using namespace std; int hubDistance(int n, int sub) { int mmax = -1; int diabeg = -1; for (int i = 1; i < n; i++) { int q = getDistance(0, i); if (q > mmax) { mmax = q; diabeg = i; } } vector<int> fbeg(n); int diaend = -1; mmax = -1; for (int i = 0; i < n; i++) { if (i == diabeg) continue; fbeg[i] = getDistance(diabeg, i); if (fbeg[i] > mmax) { mmax = fbeg[i]; diaend = i; } } vector<int> fend(n); fend[diabeg] = fbeg[diaend]; for (int i = 0; i < n; i++) { if (i == diabeg || i == diaend) continue; fend[i] = getDistance(diaend, i); } int r = 100000000; int dia = fbeg[diaend]; for (int i = 0; i < n; i++) { int diff = abs(fbeg[i] - fend[i]); r = min(r, (dia + diff)/2); } return r; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:8: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...