# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139042 | toonewbie | Rail (IOI14_rail) | C++17 | 542 ms | 98580 KiB |
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 dist[5005][5005];
void findLocation(int n, int first, int location[], int stype[]) {
location[0] = first;
stype[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
dist[i][j] = dist[j][i] = getDistance(i, j);
}
}
int mn = 1e9, two;
for (int i = 1; i < n; ++i) {
if (dist[i][0] < mn) {
mn = dist[i][0];
two = i;
}
}
location[two] = first + mn;
stype[two] = 2;
for (int j = 1; j < n; ++j) {
if (j == two) continue;
if (dist[0][j] == dist[two][j]) {
location[j] = first + dist[0][j];
stype[j] = 1;
} else if (dist[0][j] < dist[two][j]) {
location[j] = first + dist[0][j];
if (dist[0][j] == dist[j][0]) stype[j] = 2;
else stype[j] = 1;
} else if (dist[two][j] < dist[0][j]) {
location[j] = location[two] - dist[two][j];
if (dist[two][j] + dist[two][0] == dist[j][0]) stype[j] = 1;
else stype[j] = 2;
}
}
}
Compilation message (stderr)
# | 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... |