# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128640 | antimirage | Rail (IOI14_rail) | C++14 | 86 ms | 604 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 <bits/stdc++.h>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 5005;
int dist[2][N];
vector <int> lft;
bool cmp2 (int a, int b) {
return dist[1][a] < dist[1][b];
}
void findLocation(int n, int pos, int a[], int t[])
{
int mx = 0, ind, asd;
a[0] = pos, t[0] = 1;
if (n == 1) return;
for (int i = 1; i < n; i++) {
dist[0][i] = getDistance(0, i);
if (dist[0][i] > mx) {
mx = dist[0][i];
ind = i;
}
}
a[ind] = pos + mx; t[ind] = 2;
for (int i = 1; i < n; i++) {
if (i == ind) continue;
dist[1][i] = getDistance(ind, i);
lft.pb(i);
}
sort(all(lft), cmp2);
int lastc = -1, lastd = ind;
for (int i = 0; i < (int)lft.size(); i++) {
int it = lft[i];
if (lastc == -1) {
lastc = it;
a[it] = a[ind] - dist[1][it];
t[it] = 1;
}
else {
int res = getDistance(lastc, it), nxt = a[ind] - dist[1][it];
if (nxt >= 0 && res == 2 * (a[lastd] - a[lastc]) + a[lastc] - nxt) {
a[it] = nxt, lastc = it; t[it] = 1;
}
else {
a[it] = a[lastc] + res; t[it] = 2;
if (a[lastd] > a[it])
lastd = it;
}
}
}
}
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... |