이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rail.h"
#include <cassert>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
/*
int getDistance(int a, int b){
cout << a << ' ' << b << endl;
int x;
cin >> x;
return x;
}*/
void findLocation(int n, int fi, int location[], int stype[]){
vector<pair<int, int>> v;
for(int i = 1; i < n; i++){
int d = getDistance(0, i);
v.emplace_back(d, i);
}
sort(all(v));
location[0] = fi; stype[0] = 1;
if(n == 1) return;
auto [d0, x] = v[0];
location[x] = fi + d0; stype[x] = 2;
int l, r, dr, dl;
l = 0, r = x, dl = d0 * 2, dr = d0;
for(int i = 1; i < n - 1; i++){
auto&[d, x] = v[i];
//cout << "cur is : " << l << ' ' << r << ' ' << x << '\n';
int d1 = getDistance(1, x);
assert(d0 == v[0].first);
if(d0 + d1 == d){
int xl = getDistance(l, x);
if(l && d == dl + xl){
assert(false);
location[x] = location[l] + xl;
stype[x] = 2;
}
else{
location[x] = fi + 2 * d0 - d;
stype[x] = 1;
assert(location[x] < fi);
if(location[x] < fi) l = x, dl = d;
}
}
else{
int xr = getDistance(r, x);
if(d == dr + xr){
assert(false);
location[x] = fi + dr - xr;
stype[x] = 1;
}
else{
location[x] = fi + d;
stype[x] = 2;
r = x; dr = d;
}
}
}
for(int i = 0; i < n; i++) assert(stype[i] != 0);
return;
}
/*
int main(void){
int n = 4, fi = 2, a[4], b[4];
findLocation(n, fi, a, b);
for(int i = 0; i < 4; i++) cout << a[i] << ' ' << b[i] << '\n';
return 0;
}*/
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:28:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
28 | auto [d0, x] = v[0];
| ^
rail.cpp:33:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
33 | auto&[d, x] = v[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... |