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;
int ans[5005];
int diff[5005];
void solve(int N) {
diff[1] = query(1, 2);
int cur = diff[1];
int mini = 0, maxi = cur;
bool check = true;
for (int i = 2; i < N; ++i) {
int res = query(i, i + 1);
if (res + abs(diff[i - 1]) == query(i - 1, i + 1)) {
if (diff[i - 1] < 0) diff[i] = -res;
else diff[i] = res;
}
else {
if (diff[i - 1] > 0) diff[i] = -res;
else diff[i] = res;
}
cur += diff[i];
if (mini > cur) check = false, mini = cur;
else if (maxi < cur) check = true, maxi = cur;
}
int offset = 1 - mini;
if (!check) offset = 1 + maxi;
cur = offset;
for (int i = 1; i <= N; i++) {
answer(i, cur);
if (!check) cur -= diff[i];
else cur += diff[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... |