이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"rail.h"
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
void findLocation(int n,int first,int location[],int stype[]){
location[0]=0;
vector<pair<int,int>>dist0(n-1);
for(int i=0;i<n-1;i++)
dist0[i]={getDistance(0,i+1),i+1};
sort(dist0.begin(),dist0.end());
vector<int>left,right;
stype[0]=1;
for(auto[dist,i]:dist0){
if(right.empty()){
right.push_back(i);
location[i]=dist;
stype[i]=2;
continue;
}
int dist1=getDistance(right[0],i);
//cout<<dist1<<" + "<<dist0[right[0]].first<<" == "<<dist<<"\n";
if(dist1+dist0[right[0]].first==dist+1){ // i is on the left side
dist-=2*dist0[right[0]].first-2;
bool done=false;
for(int j=0;j<(int)left.size()-1;j++){
int a=location[left[j]];
int b=location[left[j+1]];
int nloc=2*a+dist;
if(a<nloc&&nloc<b){
int dist2=getDistance(left[j],i);
if(dist2-a==dist){
done=true;
location[i]=nloc;
stype[i]=2;
}
}
}
if(!done){
left.push_back(i);
location[i]=-dist;
stype[i]=1;
}
}else{ // i is on the right side
bool done=false;
for(int j=1;j<(int)right.size()-1;j++){
int a=location[right[j]];
int b=location[right[j+1]];
int nloc=2*b-dist;
if(a<nloc&&nloc<b){
int dist2=getDistance(right[j+1],i);
if(dist2+b==dist){
done=true;
location[i]=nloc;
stype[i]=1;
}
}
}
if(!done){
right.push_back(i);
location[i]=dist;
stype[i]=2;
}
}
}
for(int i=0;i<n;i++){
location[i]+=first;
//cout<<stype[i]<<" "<<location[i]<<"\n";
}
}
# | 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... |