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;
void findLocation(int N, int first, int location[], int stype[])
{
for (int i = 0; i < N; i++)
location[i] = -1;
location[0] = first, stype[0] = 1;
int cur = 0, mx = 0, mn = 1e9 + 7;
while (true) {
int curMn = 1e9 + 7, nxt = -1;
for (int i = 0; i < N; i++) {
int dis1 = getDistance(cur, i), dis2 = getDistance(0, i);
if (dis1 >= dis2 && dis1 < curMn && location[i] == -1)
curMn = dis1, nxt = i;
}
if (nxt == -1)
break;
cur = nxt;
int curDis = getDistance(0, cur);
mx = max(mx, curDis), mn = min(mn, curDis);
location[cur] = curDis + first, stype[cur] = 2;
}
for (int i = 0; i < N; i++) {
if (location[i] != -1)
continue;
int dis = getDistance(0, i) - mx - 1;
location[i] = first - dis, stype[i] = 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... |