# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129539 | johutha | Towns (IOI15_towns) | C++14 | 21 ms | 1016 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |