# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73949 | Hoget157 | Rail (IOI14_rail) | C++14 | 87 ms | 1052 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>
#define INF 1e+9
using namespace std;
typedef pair<int,int> P;
void findLocation(int n, int first, int location[], int stype[]){
location[0] = first;
stype[0] = 1;
if(n == 1) return;
if(n == 2){
int d = getDistance(0,1);
location[1] = first + d;
stype[1] = 2;
return;
}
int d0[5010] = {},d1[5010] = {},mi = INF,mii;
for(int i = 1;i < n;i++){
d0[i] = getDistance(0,i);
if(mi > d0[i]){
mi = d0[i];
mii = i;
}
}
for(int i = 0;i < n;i++){
if(mii != i) d1[i] = getDistance(mii,i);
}
for(int i = 1;i < n;i++){
if(i != mii && d0[i] > d1[i]){
stype[i] = 1;
location[i] = first - (d0[i] - 2 * d0[mii]);
}
else{
stype[i] = 2;
location[i] = first + d0[i];
}
}
//for(int i = 0;i < n;i++) cout << stype[i] << " " << location[i] << endl;
}
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... |