이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
int n;
//int getDistance(int i, int j);
void findLocation(int N, int first, int location[], int stype[]){
//1: lhs (up-down)
//2: rhs (down-up)
n=N;
location[0]=first;
stype[0]=1;
if (n==1){
return;
}
vector<pair<int,int>> distfrom0(n-1);
for (int i = 1; i<n; i++){
distfrom0[i-1]={getDistance(0,i),i};
}
sort(distfrom0.begin(),distfrom0.end());
//last c, first d
int indlastc = 0;
int indfirstd = distfrom0[0].second;
stype[indlastc]=2;
location[indlastc]=first+distfrom0[0].first;
for (int i = 2; i<n; i++){
int ind = distfrom0[i].second;
int distc = getDistance(indlastc,ind);
int distd = getDistance(indfirstd,ind);
if (distc>distd){
location[ind]=location[indfirstd]-distd;
stype[ind]=1;
} else {
location[ind]=location[indlastc]+distc;
stype[ind]=2;
}
}
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... |