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"
int z;
int l(int i, int j){return i<j?i:j;}
int h(int i, int j){return i>j?i:j;}
int ask(int i, int j) { return i-j ? getDistance(i, j): 0; }
int argmax(int x, int N) {
int mx = 0, dist = -1;
for (int y, i = 0; i < N; ++i)
if (dist < (y = ask(x, i)))
dist = y, mx = i, z = dist;
return mx;
}
int hubDistance(int N, int sub) {
int d1 = argmax(0, N);
int d2 = argmax(d1, N);
int dd = z;
int R = 1e9;
for (int i = 0; i < N; ++i) {
if (d1 == i || d2 == i)
continue;
int a=ask(d1,i),b=ask(d2,i);
int branch = (a+b-dd)/2;
R=l(R,h(a,b)-branch);
}
return R;
}
Compilation message (stderr)
towns.c: In function 'hubDistance':
towns.c:17:28: warning: unused parameter 'sub' [-Wunused-parameter]
17 | 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... |