# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
409295 | MDario | Rail (IOI14_rail) | C++11 | 88 ms | 620 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;
typedef long long ll;
#define F first
#define S second
void findLocation(int N, int first, int location[], int stype[]){
for(int i=0; i<N; i++){
stype[i]=0;
}
location[0]=first;
stype[0]=1;
if(N==1)return;
int a[N];
a[0]=0;
vector<pair<ll, ll>> v, v1;
for(int i=0; i<N; i++){
if(stype[i]==0){
a[i]=getDistance(0, i);
v.push_back({a[i], i});
}
}
sort(v.begin(), v.end());
int l=0, r=v[0].S, dl, dr;
location[r]=first+v[0].F;
stype[r]=2;
for(int i=1; i<v.size(); i++){
dl=getDistance(l, v[i].S);
dr=getDistance(r, v[i].S);
if(dl<dr){
stype[v[i].S]=2;
location[v[i].S]=location[l]+dl;
if(dl>=location[r]-location[l]){
r=v[i].S;
}
}
else{
stype[v[i].S]=1;
location[v[i].S]=location[r]-dr;
if(dr>=location[r]-location[l]){
l=v[i].S;
}
}
}
return ;
}
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... |