이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"
void solve(int n) {
vector<int> ans(n + 1);
ans[2] = ans[1] + query(1, 2);
for (int i = 3; i <= n; ++i) {
int x = query(i - 2, i);
int y = query(i - 1, i);
if (ans[i - 2] < ans[i - 1]) {
if (x == ans[i - 1] - ans[i - 2]) {
ans[i] = ans[i - 1] - y;
} else if (x == y) {
ans[i] = ans[i - 1] - y;
} else {
ans[i] = ans[i - 1] + y;
}
} else {
if (x == ans[i - 2] - ans[i - 1]) {
ans[i] = ans[i - 1] + y;
} else if (x == y) {
ans[i] = ans[i - 1] + y;
} else {
ans[i] = ans[i - 1] - y;
}
}
}
int offset = *min_element(ans.begin(), ans.end());
for (int i = 1; i <= n; ++i) {
ans[i] -= offset - 1;
}
if (find(ans.begin(), ans.end(), 1) > find(ans.begin(), ans.end(), n)) {
for (int i = 1; i <= n; ++i) {
ans[i] = n + 1 - ans[i];
}
}
for (int i = 1; i <= n; ++i) {
answer(i, ans[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... |