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 "rail.h"
#define N 5000
#define INF 999999999
int n;
int zd[N], zero;
int rd[N], rw, r_num;
void findLocation(int _n, int _zero, int out1[], int out2[]) {
int temp = INF;
n = _n, zero = _zero;
for (int i = 1; i < n; i++) {
zd[i] = getDistance(0, i);
if (temp > zd[i]) {
temp = zd[i], r_num = i;
rw = zero + temp;
}
}
for (int i = 1; i < n; i++)
if (i != r_num) rd[i] = getDistance(r_num, i);
out1[0] = zero, out2[0] = 1;
out1[r_num] = rw, out2[r_num] = 2;
for (int i = 1; i <= n; i++)
if (i != r_num) {
if (zd[i] + rw - zero == rd[i])
out1[i] = zero + zd[i], out2[i] = 2;
else if (rd[i] + rw - zero == zd[i])
out1[i] = rw - rd[i], out2[i] = 1;
}
}
# | 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... |