이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
int zero[3001];
int one[3001];
int op;
void findLocation(signed N, signed first, signed location[], signed stype[])
{
int i;
pair<int,int>mi={1LL<<60,1};
for(i=1;i<N;i++)
{
zero[i]=getDistance(0,i);
mi=min(mi,make_pair(zero[i],i));
}
stype[0]=1;
location[mi.second]=mi.first;
stype[mi.second]=2;
one[0]=mi.first;
vector<pair<int,int>>le;
vector<pair<int,int>>re;
le.push_back({one[0],0});
for(i=0;i<N;i++)
{
if(i==mi.second||i==0)
continue;
one[i]=getDistance(mi.second,i);
if(zero[i]==one[i]+mi.first)
le.push_back({one[i],i});
else
re.push_back({zero[i],i});
}
sort(le.begin(),le.end());
sort(re.begin(),re.end());
for(i=0;i<le.size();i++)
{
stype[le[i].second]=1;
location[le[i].second]=mi.first-le[i].first;
int firstdis=0;
int firstp=0;
int j;
for(j=i-1;j>=0;j--)
{
if(stype[le[j].second]==1)
{
firstdis=getDistance(le[i].second,le[j].second);
firstp=location[le[j].second];
break;
}
}
if(firstdis==0)
{
firstdis=getDistance(le[i].second,0);
firstp=0;
}
for(j=0;j<i;j++)
{
if(stype[le[j].second]==1)
{
if(firstdis-location[le[j].second]+firstp+one[le[j].second]==one[le[i].second])
{
stype[le[i].second]=2;
location[le[i].second]=firstp+firstdis;
break;
}
}
}
}
for(i=0;i<re.size();i++)
{
stype[re[i].second]=2;
location[re[i].second]=re[i].first;
int firstdis=0;
int firstp=0;
int j;
for(j=i-1;j>=0;j--)
{
if(stype[re[j].second]==2)
{
firstdis=getDistance(re[i].second,re[j].second);
firstp=location[re[j].second];
break;
}
}
if(firstdis==0)
{
firstdis=getDistance(re[i].second,mi.second);
firstp=location[mi.second];
}
for(j=0;j<i;j++)
{
if(stype[re[j].second]==2)
{
if(firstdis+location[re[j].second]-firstp+zero[re[j].second]==zero[re[i].second])
{
stype[re[i].second]=1;
location[re[i].second]=firstp-firstdis;
break;
}
}
}
}
for(i=0;i<N;i++)
location[i]+=first;
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:36:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(i=0;i<le.size();i++)
| ~^~~~~~~~~~
rail.cpp:71:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(i=0;i<re.size();i++)
| ~^~~~~~~~~~
# | 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... |