// author: erray
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
//int query(int s, int e);
//int answer(int ind, int v);
void solve(int n) {
vector<int> f(n);
f[1] = query(1, 2);
for (int i = 2; i < n; ++i) {
int th = query(i - 1, i + 1), tw = query(i, i + 1);
if (th == abs(f[i - 1])) {
f[i] = f[i - 1] + (f[i - 1] > 0 ? -1 : 1) * tw;
} else if (th > abs(f[i - 1])) {
if (tw > th) {
f[i] = f[i - 1] + (f[i - 1] > 0 ? -1 : 1) * tw;
} else {
f[i] = f[i - 1] + (f[i - 1] > 0 ? 1 : -1) * tw;
}
}
}
vector<int> pref(n);
for (int i = 0; i < n; ++i) {
pref[i] = pref[i - (i > 0)] + f[i];
}
int ind1 = (int) (max_element(pref.begin(), pref.end()) - pref.begin()), ind2 = (int) (min_element(pref.begin(), pref.end()) - pref.begin());
if (ind2 > ind1) {
swap(ind2, ind1);
for (auto& el : f) el = -el;
}
swap(ind1, ind2);
vector<int> ans(n);
ans[ind1] = 1;
for (int i = ind1 + 1; i < n; ++i) {
ans[i] = ans[i - 1] + f[i];
}
for (int i = ind1 - 1; i >= 0; --i) {
ans[i] = ans[i + 1] + -f[i + 1];
}
for (int i = 0; i < n; ++i) {
answer(i + 1, ans[i]);
}
}
Compilation message
xylophone.cpp:3:10: fatal error: grader.h: No such file or directory
3 | #include "grader.h"
| ^~~~~~~~~~
compilation terminated.