이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |