# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902211 | Muhammad_Aneeq | Rail (IOI14_rail) | C++17 | 51 ms | 628 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 <vector>
#include <algorithm>
using namespace std;
int dist(int i,int j)
{
return getDistance(i,j);
}
void findLocation(int n, int pos, int location[], int stype[])
{
int f=1e9+10;
int ind=-1;
for (int i=1;i<n;i++)
{
int z=(dist(0,i));
if (z<f)
{
f=z;
ind=i;
}
}
vector<pair<int,int>>sm,bi;
for (int i=1;i<n;i++)
{
if (i==ind)
continue;
int z=dist(ind,i);
if (dist(0,i)==z+f)
sm.push_back({z,i});
else
bi.push_back({z,i});
}
sort(begin(sm),end(sm));
sort(begin(bi),end(bi));
location[0]=pos;
stype[0]=1;
for (int i=0;i<sm.size();i++)
{
location[sm[i].second]=pos-sm[i].first+f;
stype[sm[i].second]=1;
}
for (int i=0;i<bi.size();i++)
{
location[bi[i].second]=pos+bi[i].first-f;
stype[bi[i].second]=2;
}
location[ind]=pos+f;
stype[ind]=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... |