# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
585976 | SeDunion | 철로 (IOI14_rail) | C++17 | 83 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 5055;
const int inf = 1e9;
int n, d0[N];
#define cout if(false)cout
void findLocation(int N, int first, int location[], int stype[]) {
n = N;
vector<pair<int,int>>v;
for (int i = 1 ; i < n ; ++ i) {
d0[i] = getDistance(0, i);
v.emplace_back(d0[i], i);
}
sort(v.begin(), v.end());
int L = 0, R = v[0].second;
stype[0] = 1, location[0] = first;
stype[R] = 2, location[R] = first + v[0].first;
set<int>LL,RR;
int dlr = v[0].first;
for (int i = 1 ; i < (int)v.size() ; ++ i) {
LL.insert(location[L]);
RR.insert(location[R]);
int di = v[i].first, k = v[i].second;
int dl = getDistance(L, k);
int dr = getDistance(R, k);
int X = location[L];
int Y = location[R];
int Z = Y - dr;
cout << X << " " << Y << " | " << dl << " " << dr << endl;
if (Z < X) {
int D = X - Z;
int C = dl - D;
if (C % 2 == 0) {
C /= 2;
C = X + C;
if (*RR.lower_bound(X) == C) {
stype[k] = 1;
location[k] = Z;
L = k;
continue;
}
}
} else {
int D = Z - X;
int C = dl - D;
if (C % 2 == 0) {
C /= 2;
C = X + dl - C;
if (*RR.lower_bound(Z) == C) {
stype[k] = 1;
location[k] = Z;
LL.insert(location[k]);
continue;
}
}
}
Z = X + dl;
if (Y < Z) {
stype[k] = 2;
location[k] = Z;
R = k;
continue;
int D = Z - Y;
int C = dr - D;
if (C % 2 == 0) {
C /= 2;
C = Y - C;
if (*prev(LL.upper_bound(Y)) == C) {
stype[k] = 2;
location[k] = Z;
R = k;
continue;
}
}
} else {
stype[k] = 2;
location[k] = Z;
RR.insert(location[k]);
continue;
int D = Y - Z;
int C = dr - D;
if (C % 2 == 0) {
C /= 2;
C = Y - dr + C;
if (*prev(LL.upper_bound(Z)) == C) {
stype[k] = 2;
location[k] = Z;
RR.insert(location[k]);
continue;
}
}
}
}
for (int i = 0 ; i < n ; ++ i) {
cout << stype[i] << " " << location[i] << endl;
}
}
컴파일 시 표준 에러 (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... |