# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
802247 | caganyanmaz | Towns (IOI15_towns) | C++17 | 14 ms | 716 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 <bits/stdc++.h>
#include "towns.h"
using namespace std;
constexpr static int INF = 2e9;
constexpr static int MXSIZE = 110;
int n;
int jdist[MXSIZE];
int hubDistance(int N, int sub)
{
n = N;
int mxdist = 0;
int j = 0;
for (int i = 1; i < n; i++)
{
int val = getDistance(0, i);
if (val > mxdist)
{
j = i;
mxdist = val;
}
}
int k = 0;
jdist[0] = mxdist;
for (int i = 1; i < n; i++)
{
if (i == j)
continue;
int val = getDistance(i, j);
jdist[i] = val;
if (val > mxdist)
{
k = i;
mxdist = val;
}
}
int r = mxdist;
for (int i = 0; i < n; i++)
{
if (i == j || i == k)
continue;
int da = jdist[i];
int db = getDistance(i, k);
int change = (da + db - mxdist) / 2;
r = min(r, max(da - change, db - change));
}
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... |