# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551557 | AJ00 | Rail (IOI14_rail) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
#include <rail.h>
using namespace std;
void findLocation(int N, int first, int[] location, int[] stype){
int n = N;
location[0] = first;
stype[0] = 1;
if (n == 1){
return;
}
for (int i = 0; i < n; i++){
stype[i] = -1;
for (int j = i+1; j < n; j++){
dist[i][j] = getDistance(i,j);
dist[j][i] = dist[i][j];
}
}
stype[0] = 1;
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (dist[0][i] == dist[0][j]+dist[i][j]){
location[j] = dist[0][j]+location[0];
location[i] = location[j]-dist[i][j];
stype[j] = 2;
stype[i] = 1;
}
else if (dist[0][j] == dist[0][i]+dist[i][j]){
location[i] = dist[0][i]+location[0];
location[j] = location[i]-dist[i][j];
stype[i] = 2;
stype[j] = 1;
}
}
}
for (int i = 0; i < n; i++){
if (stype[i] == -1){
location[i] = dist[0][i]+location[0];
stype[i] = 2;
}
}
return;
}