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 <vector>
#include <cmath>
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i<n; i++)
#define pb push_back
void findLocation(int N, int first, int location[], int stype[])
{
vi cs;
vi ds;
vi zdists;
rep(i, N) {
zdists.pb(getDistance(0, i));
}
rep(i, (N-1)/2) {
int newdist = getDistance(2*i + 1, 2*i + 2);
int dist1 = zdists[2*i + 1];
int dist2 = zdists[2*i + 2];
if (newdist == dist1 + dist2) {
ds.pb(2*i + 1);
ds.pb(2*i + 2);
}
else if (newdist == dist1 - dist2) {
cs.pb(2*i + 1);
ds.pb(2*i + 2);
}
else if (newdist == dist2 - dist1) {
ds.pb(2*i + 1);
cs.pb(2*i + 2);
}
else {
cs.pb(2*i + 1);
cs.pb(2*i + 2);
}
}
if (N % 2 == 0) {
int i = N - 2;
int newdist = getDistance(i + 1, i);
int dist1 = zdists[i + 1];
int dist2 = zdists[i];
if (newdist == dist1 + dist2) {
ds.pb(i + 1);
}
else if (newdist == dist1 - dist2) {
cs.pb(i + 1);
}
else if (newdist == dist2 - dist1) {
ds.pb(i + 1);
}
else {
cs.pb(i + 1);
}
}
for (auto d : ds) {
location[d] = first + zdists[d];
stype[d] = 2;
}
int fd = ds[0];
for (auto c : cs) {
location[c] = location[fd] - getDistance(fd, c);
stype[c] = 1;
}
stype[0] = 1;
location[0] = first;
return;
}
# | 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... |