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 dist[MXSIZE][MXSIZE];
int get_dist(int i, int j)
{
return dist[max(i, j)][min(i, j)];
}
int hubDistance(int N, int sub)
{
n = N;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
dist[j][i] = getDistance(i, j);
int a = 0, b = 0;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
if (get_dist(i, j) > get_dist(a, b))
a = i, b = j;
int r = INF;
for (int i = 0; i < n; i++)
{
int da = get_dist(i, a);
int db = get_dist(i, b);
int dc = (da + db - get_dist(a, b)) / 2;
r = min(r, max(da - dc, db - dc));
}
return r;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:16:28: warning: unused parameter 'sub' [-Wunused-parameter]
16 | int hubDistance(int N, int sub)
| ~~~~^~~
# | 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... |