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 <bits/stdc++.h>
using namespace std;
const int N = 115, INF = 1000000009;
int n;
int ans[N][N];
int qry(int x, int y)
{
if (ans[x][y] != -1)
return ans[x][y];
return ans[x][y] = ans[y][x] = getDistance(x, y);
}
int hubDistance(int N_, int sub)
{
n = N_;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (i == j)
continue;
ans[i][j] = -1;
}
}
int maxu = -1;
int maxx;
for (int x = 0; x < n; ++x)
{
if (qry(0, x) > maxu)
{
maxu = qry(0, x);
maxx = x;
}
}
int u1 = maxx;
maxu = -1;
for (int x = 0; x < n; ++x)
{
if (qry(u1, x) > maxu)
{
maxu = qry(u1, x);
maxx = x;
}
}
int u2 = maxx;
int R = INF;
for (int x = 0; x < n; ++x)
{
int t1 = qry(u1, u2);
int t2 = qry(u1, x);
int t3 = qry(u2, x);
R = min(R, max((t1 + t3 - t2) / 2, max((t1 + t2 - t3) / 2, (t2 + t3 - t1) / 2)));
}
return R;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:16:29: warning: unused parameter 'sub' [-Wunused-parameter]
16 | int hubDistance(int N_, int sub)
| ~~~~^~~
towns.cpp:30:9: warning: 'maxx' may be used uninitialized in this function [-Wmaybe-uninitialized]
30 | int maxx;
| ^~~~
# | 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... |