This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5005;
int A[MAX];
void solve(int N) {
A[2] = query(1, 2);
for (int i = 3; i <= N; ++i) {
int d1 = query(i - 1, i);
int d2 = query(i - 2, i);
if (abs(A[i - 1] - A[i - 2]) + d1 == d2) {
if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] + d1;
else A[i] = A[i - 1] - d1;
}
else {
if (A[i - 2] < A[i - 1]) A[i] = A[i - 1] - d1;
else A[i] = A[i - 1] + d1;
}
}
int off = *min_element(A + 1, A + N + 1);
for (int i = 1; i <= N; ++i) A[i] = A[i] - off + 1;
if (min_element(A + 1, A + N + 1) - max_element(A + 1, A + N + 1) > 0) {
for (int i = 1; i <= N; ++i) A[i] = N + 1 - A[i];
}
for(int i = 1; i <= N; i++) answer(i, A[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... |