#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
using ll = long long;
const int mod = 1e9+7;
void solve(int n) {
vector<vector<int>> diff(n+1, vector<int>(n+1));
for (int i = 1; i < n; ++i) {
diff[i][i+1] = query(i, i+1);
}
for (int i = 1; i < n-1; ++i) {
diff[i][i+2] = query(i, i+2);
}
vector<int> rel(n);
rel[1] = diff[1][2];
bool inc = true;
for (int i = 2; i < n; ++i) {
inc ^= (diff[i-1][i] + diff[i][i+1] != diff[i-1][i+1]);
rel[i] = rel[i-1] + diff[i][i+1] * (inc?1:-1);
}
array<int, 2> mx = {0, 0}, mn = {0, 0};
for (int i = 1; i < n; ++i) {
if (rel[i] > mx[0]) {
mx = {rel[i], i};
}
if (rel[i] < mn[0]) {
mn = {rel[i], i};
}
}
if (mn[1] < mx[1]) {
for (int i = 0; i < n; ++i) {
answer(i+1, rel[i] - mn[0] + 1);
}
} else {
for (int i = 0; i < n; ++i) {
answer(i+1, mx[0] - rel[i] + 1);
}
}
}
/*
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
return 0;
}
*/
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:18:24: error: 'query' was not declared in this scope
18 | diff[i][i+1] = query(i, i+1);
| ^~~~~
xylophone.cpp:21:24: error: 'query' was not declared in this scope
21 | diff[i][i+2] = query(i, i+2);
| ^~~~~
xylophone.cpp:41:13: error: 'answer' was not declared in this scope
41 | answer(i+1, rel[i] - mn[0] + 1);
| ^~~~~~
xylophone.cpp:45:13: error: 'answer' was not declared in this scope
45 | answer(i+1, mx[0] - rel[i] + 1);
| ^~~~~~