이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#define N 5000
#define INF 999999999
int n;
int zd[N], zero;
int rd[N], rw, r_num;
int left_num, left;
int right_num, right;
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;
left_num = 0, left = zero;
right_num = r_num, right = rw;
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;
if (out1[i] && left > out1[i])
left = out1[i], left_num = i;
if (out1[i] && right > out1[i])
right = out1[i], right_num = i;
}
for (int i = 1; i <= n; i++)
if (!out2[i]) {
temp = getDistance(left_num, i);
if (left + temp < right)
out1[i] = left + temp, out2[i] = 2;
else
out1[i] = right * 2 - left - temp, 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... |