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"
#include <bits/stdc++.h>
using namespace std;
int d[105][105];
void findLocation(int N, int first, int location[], int stype[]) {
for (int i = 0; i < N; i ++) {
d[i][i] = 0;
for (int j = i + 1; j < N; j ++) {
d[i][j] = d[j][i] = getDistance(i, j);
}
}
int nxt = -1, mn = 1e9;
for (int i = 1; i < N; i ++) {
if (mn > d[0][i]) {
mn = d[0][i];
nxt = i;
}
}
stype[0] = 1;
location[0] = first;
stype[nxt] = 2;
location[nxt] = first + mn;
for (int i = 1; i < N; i ++) {
if (i == nxt) continue;
if (d[0][i] == d[0][nxt] + d[nxt][i]) {
stype[i] = 1;
location[i] = first - d[0][i] + 2 * d[0][nxt];
}
else {
stype[i] = 2;
location[i] = first + d[0][i];
}
}
}
# | 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... |