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;
#define mp make_pair
typedef pair<int, int> ii;
const int len = 115;
map<ii, int> mym;
int disa[len], disb[len];
int ask(int a, int b){
if (a > b)
swap(a, b);
if (mym.count(mp(a, b)))
return mym[mp(a, b)];
return mym[mp(a, b)] = getDistance(a, b);
}
int hubDistance(int n, int sub) {
mym.clear();
int a = 0, b = 0;
for (int i = 0; i < n; i++)
if (ask(a, i) > ask(a, b))
b = i;
for (int i = 0; i < n; i++)
if (ask(i, b) > ask(a, b))
a = i;
int R = ask(a, b);
for (int c = 0; c < n; c++){
disa[c] = (ask(a, b)+ask(a, c)-ask(b, c))/2;
disb[c] = ask(a, b)-disa[c];
R = min(R, max(disa[c], disb[c]));
}
return R;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:20:28: warning: unused parameter 'sub' [-Wunused-parameter]
20 | 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... |