이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
static map <pair <int, int>, int> qry;
inline int query(int a, int b) {
if(a > b) swap(a, b);
if(qry[{a, b}]) {
return qry[{a, b}];
}
return qry[{a, b}] = getDistance(a, b);
}
void findLocation(int n, int first, int location[], int stype[]) {
location[0] = first;
stype[0] = 1;
vector < pair <int, int> > arr;
int i, l = 0;
for(i = 1; i < n; i++) {
arr.push_back({query(0, i), i});
}
sort(arr.begin(), arr.end());
int r = arr[0].second;
location[r] = arr[0].first + first;
stype[r] = 2;
for(i = 1; i < arr.size(); i++) {
int k = arr[i].second;
int dst = location[r] - location[l];
if(query(l, k) < dst) {
location[k] = location[l] + query(l, k);
stype[k] = 2;
continue;
}
if(query(r, k) < dst) {
location[k] = location[r] - query(r, k);
stype[k] = 1;
continue;
}
if(query(l, k) < query(r, k)) {
location[k] = location[l] + query(l, k);
stype[k] = 2;
r = k;
}
else {
location[k] = location[r] - query(r, k);
stype[k] = 1;
l = k;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i = 1; i < arr.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... |