이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
#include "rail.h"
int dist0[5005],mval=2e9,mpos,distm[5005];
void findLocation(int n, int f, int location[], int stype[]){
if(n==1){
location[0] = f;
stype[0] = 1;
return;
}
for(int i=1;i<=n-1;i++){
dist0[i] = getDistance(0,i);
if(dist0[i]<mval){
mval = dist0[i];
mpos = i;
}
}
for(int i=0;i<=n-1;i++){
if(i!=mpos){
distm[i] = getDistance(mpos,i);
}
}
location[0] = f;
location[mpos] = f+dist0[mpos];
stype[0] = 1;
stype[mpos] = 2;
vector<pair<int,int>> lef,rit;
for(int i=1;i<=n-1;i++){
if(i!=mpos){
if(distm[i]<=dist0[mpos]){
location[i] = location[mpos]-distm[i];
stype[i] = 1;
}
else if(dist0[i]>distm[i]){
lef.push_back({distm[i],i});
}
else{
rit.push_back({dist0[i],i});
}
}
}
sort(lef.begin(),lef.end());
sort(rit.begin(),rit.end());
int maxc = 0;
for(pair<int,int> i:lef){
int p = getDistance(maxc,i.second);
if(p>i.first){
maxc = i.second;
location[i.second] = location[mpos]-i.first;
stype[i.second] = 1;
}
else{
location[i.second] = location[maxc]+p;
stype[i.second] = 2;
}
}
int maxd = mpos;
for(pair<int,int> i:rit){
int p = getDistance(maxd,i.second);
if(p>i.first){
maxd = i.second;
location[i.second] = f+i.first;
stype[i.second] = 2;
}
else{
location[i.second] = location[maxd]-p;
stype[i.second] = 1;
}
}
}
# | 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... |