This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ...b ){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 5005
#define pii pair<int, int>
#define ff first
#define ss second
void findLocation(int N, int first, int location[], int stype[]) {
vector<pii> d;
for (int i = 1;i < N;i++) {
d.push_back({getDistance(0, i), i});
}
location[0] = first;
stype[0] = 1;
if (N == 1) return;
sort(d.begin(), d.end());
int lid = 0, rid = d[0].ss;
int lef = first, rig = first + d[0].ff;
location[rid] = rig;
stype[rid] = 2;
for (int i = 1;i < N - 1;i++) {
int id = d[i].ss;
int vl = getDistance(lid, id), vr = getDistance(rid, id);
if (vl < vr) {
location[id] = lef + vl;
stype[id] = 2;
if (lef + vl > rig) {
rig = lef + vl;
rid = id;
}
} else {
location[id] = rig - vr;
stype[id] = 1;
if (rig - vr < lef) {
lef = rig - vr;
lid = id;
}
}
}
}
# | 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... |