이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma once
#include "rail.h"
using ll =long long;
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
using namespace std;
int minind(vi &v){
int mn=v[0];
int m=0;
for(int i=1;i<v.size();i++){
if(v[i]<mn){
mn=v[i];
m=i;
}
}
return m;
}
int getDistance(int i, int j);
void findLocation(int n, int first, int location[], int stype[]){
for(int i=0;i<n;i++){
location[i]=0;
stype[i]=0;
}
vi d0(n),ds(n);
for(int i=1;i<n;i++){
d0[i]= getDistance(0,i);
}
d0[0]=INF;
int second=minind(d0);
d0[0]=0;
for(int i=1;i<n;i++){
if(i==second)continue;
int dist= getDistance(i,second);
ds[i]=dist;
}
stype[0]=1;
stype[second]=2;
location[0]=first;
location[second]=first+d0[second];
for(int i=0;i<n;i++){
if(stype[i])continue;
if(d0[i]<d0[second] && ds[i]<d0[second]){
stype[i]=1;
location[i]=first+d0[i];
}
}
vector<pi>right,left;
for(int i=0;i<n;i++){
if(stype[i])continue;
if(d0[i]==d0[second]+ds[i]){
left.push_back(make_pair(ds[i],i));
}
else right.push_back(make_pair(d0[i],i));
}
std::sort(right.begin(), right.end());
std::sort(left.begin(), left.end());
int last=second;
for(auto p:right){
int i=p.second;
int dist= getDistance(i,last);
if(d0[i]==d0[last]+dist){
stype[i]=1;
location[i]= location[last]-dist;
}
else{
stype[i]=2;
location[i]=first+d0[i];
last=i;
}
}
last = 0;
for( auto p:left){
int i=p.second;
int dist= getDistance(i,last);
if(ds[i]==ds[last]+dist){
stype[i]=2;
location[i]=location[last]+dist;
}
else {
stype[i]=1;
location[i]=location[second]-ds[i];
last=i;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp:2:9: warning: #pragma once in main file
2 | #pragma once
| ^~~~
rail.cpp: In function 'int minind(std::vector<int>&)':
rail.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | 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... |