#include<bits/stdc++.h>
//#include "xylophone.h"
using namespace std;
using int = long long;
int a[5002], ans[5002];
/*
int query(int l, int r) {
int mx, mn;
mx = mn= a[l];
for (int j = l; j <= r; j ++) mx = max(mx, a[j]), mn = min(mn, a[j]);
return mx - mn;
}
*/
void solve(int N) {
int mid,i, s,x1, x2, p, n = N, lo, hi;
lo = 1;
hi = n;
while (lo < hi) {
mid = (lo + hi)/2;
if ( query(1, mid) == n - 1) hi = mid;
else lo = mid + 1;
}
ans[lo] = n;
ans[lo - 1] = n - query(lo - 1, lo);
for ( i = lo - 2; i >= 1; i --) {
s = query(i, i + 1);
p = query(i, i + 2);
x1 = ans[i + 1] - s;
x2 = ans[i + 1] + s;
if ( max(x1, max(ans[i + 1], ans[i + 2])) - min(x1, min(ans[i + 1], ans[i + 2])) == p) {
ans[i] = x1;
}
if ( max(x2, max(ans[i + 1], ans[i + 2])) - min(x2, min(ans[i + 1], ans[i + 2])) == p) {
ans[i] = x2;
}
}
ans[lo + 1] = n - query(lo, lo + 1);
for ( i = lo + 2; i <= n; i ++) {
s = query(i - 1, i);
p = query(i - 2, i);
x1 = ans[i - 1] - s;
x2 = ans[i - 1] + s;
if ( x1 >= 1 && x1 <= n && max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) {
ans[i] = x1;
}
if ( x2 >= 1 && x2 <= n && max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) {
ans[i] = x2;
}
}
for (i = 1; i <= n; i ++) cout << answer(ans[i], i) << " ";
}
/*
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
solve(n);
}
*/
Compilation message
xylophone.cpp:5:7: error: expected nested-name-specifier before 'int'
5 | using int = long long;
| ^~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:23:8: error: 'query' was not declared in this scope
23 | if ( query(1, mid) == n - 1) hi = mid;
| ^~~~~
xylophone.cpp:27:20: error: 'query' was not declared in this scope
27 | ans[lo - 1] = n - query(lo - 1, lo);
| ^~~~~
xylophone.cpp:55:36: error: 'answer' was not declared in this scope
55 | for (i = 1; i <= n; i ++) cout << answer(ans[i], i) << " ";
| ^~~~~~