이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
#define N 5005
using namespace std;
int d[N][N];
int get(int i,int j){
if(i > j)swap(i,j);
if(i == j)return 0;
if(d[i][j])
return d[i][j];
return d[i][j] = getDistance(i,j);
}
void findLocation(int n, int first, int location[], int stype[])
{
for(int i = 0;i<n;i++){
location[i] = -1;
stype[i] = -1;
}
location[0] = first;
stype[0] = 1;
if(n == 1)return;
vector<pair<int,int>> v;
for(int i = 0;i<n;i++){
if(i == 0)continue;
v.push_back({get(0,i),i});
}
sort(v.begin(),v.end());
int last = v[0].second;
int x = last;
set<int> points = {location[last]};
location[v[0].second] = get(0,v[0].second) + first;
stype[v[0].second] = 2;
for(int i = 1;i<v.size();i++){
if(get(0,v[i].second) > 2*get(0,x) && get(0,v[i].second) > get(x,v[i].second) + get(0,x) - 2)
continue;
int nwpoint = location[last] - get(last, v[i].second);
int rval = *points.lower_bound(nwpoint);
if(2*rval - nwpoint + first == get(0,v[i].second)){
location[v[i].second] = nwpoint;
stype[v[i].second] = 1;
}
else{
location[v[i].second] = get(0,v[i].second) + first;
stype[v[i].second] = 2;
last = v[i].second;
points.insert(location[last]);
}
}
for(int i = 0;i<n;i++){
cout << location[i] << " " << stype[i] << endl;
}
cout << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i = 1;i<v.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... |