# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
986446 | Yazan_SA | 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.
#pragma once
#include "bits/stdc++.h"
#include "grader.h"
using namespace std;
// int getDistance(int i, int j);
void findLocation(int n, int first, int location[], int stype[])
{
stype[0]=1;
location[0]=first;
int mn=1e9,mni;
for(int i=1; i<n; i++)
{
if(getDistance(0,i)<mn)
mn=getDistance(0,i),mni=i;
}
stype[mni]=2;
location[mni]=first+getDistance(0,mni);
for(int i=1; i<n; i++)
{
if(i==mni)continue;
if(getDistance(i,0)>getDistance(i,mni))
stype[i]=1,location[i]=location[mni]-getDistance(i,mni);
else
stype[i]=2,location[i]=first+getDistance(i,0);
}
return;
}