# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730295 | ogibogi2004 | 철로 (IOI14_rail) | C++14 | 90 ms | 772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;
void findLocation(int N, int first, int location[], int stype[])
{
memset(stype,0,sizeof(stype));
memset(location,0,sizeof(location));
location[0]=first;
stype[0]=1;
map<int,int> mtype;
mtype[location[0]]=1;
vector<pair<int,int> >distances;
vector<int>dist0(N);
vector<int>dist1(N);
for(int i=1;i<N;i++)
{
distances.push_back({getDistance(0, i),i});
dist0[i]=distances.back().first;
}
sort(distances.begin(),distances.end());
location[distances[0].second]=location[0]+distances[0].first;
stype[distances[0].second]=2;
mtype[location[distances[0].second]]=2;
set<int>cs;
set<int>ds;
int minc=0,maxd=distances[0].second,sec=maxd;
cs.insert(location[0]);
ds.insert(location[distances[0].second]);
for(int i=1;i<N;i++)
{
if(i==maxd)continue;
dist1[i]=getDistance(maxd,i);
}
for(int i=1;i<distances.size();i++)
{
int j=distances[i].second;
if(dist0[j]==dist1[j]+dist0[sec])
{
//left of sec
if(dist1[j]<dist0[sec])
{
//between 0 and sec
location[j]=location[sec]-dist1[j];
stype[j]=1;
mtype[location[j]]=1;
}
else
{
//left of 0
//can be C or D
//if D, there should be C before it
//C X 0 D
//calc dist(minc,X) => if dist(minc,X)+location[sec]-location[minc]==dist1[minc], ok, it is D
int t=getDistance(minc,j);
int pos1=(t+location[sec]-dist1[j]+location[minc])/2;
if(mtype[pos1]!=1)
{
stype[j]=1;
location[j]=location[sec]-dist1[j];
minc=j;
mtype[location[j]]=1;
}
else
{
stype[j]=2;
location[j]=location[minc]+t;
mtype[location[j]]=2;
}
}
}
else
{
//cout<<j<<" ?2\n";
//right of sec
//0 D X D
//if X=C, then getDist(maxd,X)+location[maxd]-location[0]=dist0[X]
int t=getDistance(j, maxd);
int pos1=(-t+location[0]+dist0[j]+location[maxd])/2;
//7-
//cout<<pos1<<" "<<(-t+location[0]+dist0[j]+location[maxd])<<endl;
if(mtype[pos1]!=2)
{
stype[j]=2;
location[j]=location[0]+dist0[j];
maxd=j;
mtype[location[j]]=2;
}
else
{
stype[j]=1;
location[j]=location[maxd]-t;
mtype[location[j]]=1;
}
}
}
/*for(int i=0;i<N;i++)
{
cout<<i<<": "<<location[i]<<" "<<stype[i]<<endl;
}*/
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |