# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1032186 | juicy | Xylophone (JOI18_xylophone) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
void solve(int N) {
vector<int> A(N), qry(N);
A[1] = qry[1] = query(1, 2);
for (int i = 2; i < N; ++i) {
qry[i] = query(i, i + 1);
int a = A[i - 2], b = A[i - 1], &c = A[i];
int AB = qry[i - 1], BC = qry[i], AC = query(i - 1, i + 1);
if (AB == AC) {
if (a < b) {
c = b - BC;
} else {
c = b + BC;
}
} else if (BC == AC) {
if (a < b) {
c = b - BC;
} else {
c = b + BC;
}
} else {
if (a < b) {
c = b + BC;
} else {
c = b - BC;
}
}
}
vector<int> ord(N); iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int u, int v) {
return A[u] < A[v];
});
if (ord[0] > ord.back()) {
reverse(ord.begin(), ord.end());
}
for (int i = 0; i < N; ++i) {
answer(ord[i] + 1, i + 1);
}
}