이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
void findLocation(int n, int first, int location[], int stype[]){
stype[0] = 1;
location[0] = first;
vector<pair<int, int>> dist0;
for(int i = 1; i < n; i++){
int d = getDistance(0, i);
dist0.emplace_back(d, i);
}
sort(dist0.begin(), dist0.end());
stype[dist0[0].second] = 2;
location[dist0[0].second] = first+dist0[0].first;
map<int, int> C, D;
C.emplace(first, 0);
D.emplace(location[dist0[0].second], dist0[0].second);
for(int i = 1; i < n-1; i++){
auto [d0, ind] = dist0[i];
int dc = getDistance(C.begin()->second, ind);
int dd = getDistance(D.rbegin()->second, ind);
int rd = D.rbegin()->first;
int rc = C.rbegin()->first;
int ld = D.begin()->first;
int lc = C.begin()->first;
if(first+d0 == rd+dd-2*(rd-rc)){
stype[ind] = 2;
location[ind] = first+d0;
D.emplace(first+d0, ind);
}
else if(rd-dd > first){
stype[ind] = 1;
location[ind] = rd-dd;
C.emplace(rd-dd, ind);
}
else{
d0 = first-(rd-dd);
if(first-d0 == lc-dc+2*(ld-lc)){
stype[ind] = 1;
location[ind] = first-d0;
C.emplace(first-d0, ind);
}
else{
stype[ind] = 2;
location[ind] = lc+dc;
D.emplace(lc+dc, ind);
}
}
}
}
# | 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... |