# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043729 | pravcoder | Rail (IOI14_rail) | C++14 | 33 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 <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;
zdists.pb(0);
rep(i, N - 1) {
zdists.pb(getDistance(0, i + 1));
}
for (int i = 1; i < N-1; i++) {
int newdist = getDistance(i, N-1);
int dist1 = zdists[i];
int dist2 = zdists[N-1];
if (newdist == dist1 + dist2) {
ds.pb(i);
ds.pb(N-1);
//cout << "found d\n";
}
else if (newdist == dist1 - dist2) {
//cs.pb(i);
ds.pb(N-1);
//cout << "found d\n";
}
else if (newdist == dist2 - dist1) {
ds.pb(i);
//cs.pb(2*i + 2);
//cout << "found d\n";
}
}
int fd = ds[0];
ds.resize(1, N-1);
//cout << "finding cs\n";
int mind = N - 1;
rep(i, N) {
if (i != fd) {
//cout << "testing " << i << "\n";
if (i == 0) {
cs.pb(i);
}
else {
int newdist = getDistance(i, fd);
int dist1 = zdists[i];
int dist2 = zdists[fd];
//cout << " ? ";
if (newdist == dist1 + dist2) {
ds.pb(i);
if (zdists[i] < zdists[fd]) {
mind = i;
}
}
else {
cs.pb(i);
}
}
}
}
for (auto d : ds) {
location[d] = first + zdists[d];
stype[d] = 2;
}
for (auto c : cs) {
location[c] = first + zdists[fd] - getDistance(fd, c);
stype[c] = 1;
}
stype[0] = 1;
location[0] = first;
return;
}
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... |