#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int A[5000];
void solve(int N) {
vector<int> ans;
ans.push_back(0);
int val = query(1, 2);
ans.push_back(val);
for (int i = 2; i < N; i++) {
int val1 = query(i - 1, i + 1);
int val2 = query(i, i + 1);
int prev1 = ans[i - 2];
int prev2 = ans[i - 1];
int crnt = prev2 - val2;
int minv = min(min(prev1, prev2), crnt);
int maxv = max(max(prev1, prev2), crnt);
if (maxv - minv == val1) {
ans.push_back(crnt);
}
else {
ans.push_back(prev2 + val2);
}
}
int minelem = INT_MAX;
for (int i = 0; i < N; i++) {
minelem = min(minelem, ans[i]);
}
int adding = 1 - minelem;
for (int i = 0; i < N; i++) {
ans[i] += adding;
}
bool found1 = false;
bool reversed = false;
for (int i = 0; i < N; i++) {
if (ans[i] == 1) {
found1 = true;
}
if (ans[i] == N && !found1) {
reversed = true;
}
}
for (int i = 0; i < N; i++) {
if (reversed) {
answer(i + 1, N + 1 - ans[i]);
}
else {
answer(i + 1, 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... |