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>
#define pb push_back
#define F first
#define S second
using namespace std;
using ll = long long int;
using pll = pair<ll, ll>;
ll n, l, r;
ll tt[1000010];
vector<pll> vec;
void findLocation(int N, int first, int location[], int stype[])
{
n = N;
l = 0;
location[0] = first;
stype[0] = 1;
tt[location[0]] = 0;
for(ll i = 1; i < n; i++){
vec.pb({getDistance(0, i), i});
}
sort(vec.begin(), vec.end());
if(n == 1) return;
r = vec[0].S;
location[r] = location[l] + vec[0].F;
tt[location[r]] = 1;
stype[r] = 2;
for(ll i = 1; i < n - 1; i++){
ll k = vec[i].S;
ll x = location[l] + getDistance(l, k), y = location[r] - getDistance(r, k);
ll m = (x + y) / 2;
if(tt[m]){
location[k] = y;
tt[y] = stype[k] = 0;
if(y < location[l]) l = k;
}else{
location[k] = x;
tt[x] = stype[k] = 1;
if(x > location[r]) r = k;
}
stype[k]++;
}
}
# | 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... |