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;
const int MX = 2e7;
void findLocation(int N, int first, int location[], int stype[])
{
location[0] = first;
stype[0] = 1;
vector<int> curdis1(N, MX), vis(N, 0);
curdis1[0] = 0;
int cmin = MX, sec = -1;
for(int i=1;i<N;i++)
{
int d = getDistance(0, i);
curdis1[i] = d;
if(d < cmin)
{
cmin = d;
sec = i;
}
}
location[sec] = first + cmin, stype[sec] = 2;
vis[0] = 1;
for(int i=1;i<N;i++)
{
int nxt = MX, cids = MX;
for(int j=0;j<N;j++)
{
if(vis[j])
continue;
if(cids > curdis1[j])
cids = curdis1[j], nxt = j;
}
for(int j=0;j<N;j++)
{
if(vis[j] && j == nxt)
continue;
int curd = getDistance(nxt, j), delta = (stype[nxt] == 1 ? +1 : -1);
if(curd > curdis1[j])
{
curdis1[j] = curd;
location[j] = location[nxt] + curd * delta;
stype[j] = (stype[nxt] == 1 ? 2 : 1);
}
}
vis[nxt] = 1;
}
}
# | 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... |