이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <algorithm>
#include <vector>
using namespace std;
pair <int,int> A[5000];
vector <int> Up;
vector <int> Down;
int Check[5000];
void findLocation(int N, int First, int location[], int stype[])
{
int i, j, k, Left, Right, Dist, OK;
location[0]=First;
stype[0]=1;
for(i=1 ; i<N ; i++)
A[i]=make_pair(getDistance(0,i),i);
sort(A,A+N);
location[A[1].second]=location[0]+A[1].first;
stype[A[1].second]=2;
for(i=2 ; i<N ; i++)
{
Dist=getDistance(A[1].second,A[i].second);
if(A[i].first==A[1].first+Dist && location[A[1].second]-Dist<location[0])
Check[A[i].second]=Dist;
}
Right=A[1].second;
Up.push_back(A[1].second);
for(i=2 ; i<N ; i++)
if(!Check[A[i].second])
{
OK=1;
Dist=getDistance(Right,A[i].second);
k=Up.size();
for(j=0 ; j<k && OK ; j++)
{
if(A[i].first==(location[Up[j]]-location[0])+(Dist-(location[Right]-location[Up[j]])))
{
location[A[i].second]=location[Right]-Dist;
stype[A[i].second]=1;
OK=0;
}
}
if(OK)
{
location[A[i].second]=location[0]+A[i].first;
stype[A[i].second]=2;
Right=A[i].second;
Up.push_back(A[i].second);
}
}
Left=0;
Down.push_back(0);
for(i=2 ; i<N ; i++)
if(Check[A[i].second])
{
OK=1;
Dist=getDistance(Left,A[i].second);
k=Down.size();
for(j=0 ; j<k && OK ; j++)
{
if(Check[A[i].second]==(location[A[1].second]-location[Down[j]])+(Dist-(location[Down[j]]-location[Left])))
{
location[A[i].second]=location[Left]+Dist;
stype[A[i].second]=2;
OK=0;
}
}
if(OK)
{
location[A[i].second]=location[A[1].second]-Check[A[i].second];
stype[A[i].second]=1;
Left=A[i].second;
Down.push_back(A[i].second);
}
}
}
# | 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... |