#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"
static int A[5000];
void solve(int N){
vector<int> diff(n+1);
FOR(i,1,n){
diff[i] = query(i, i+1);
}
vector<int> type(n+1, -1);
type[1] = 1;
FOR(i,1,n-1){
int e = query(i, i+2);
if (e == diff[i]+diff[i+1]){
type[i+1] = type[i];
}else{
type[i+1] = type[i]^1;
}
}
vector<int> a(n+1);
FOR(i,1,n){
if (type[i] == 1){
a[i+1] = a[i]+diff[i];
}else{
a[i+1] = a[i]-diff[i];
}
}
int mini = 1e9; int maxi = 0;
int minind = 0; int maxind = 0;
FOR(i,1,n+1){
if (a[i] < mini){
minind = i;
}
if (a[i] > maxi){
maxind = i;
}
mini = min(mini, a[i]);
maxi = max(maxi, a[i]);
}
// printVector(a);
if (maxi - mini == n-1 && maxind > minind){
FOR(i,1,n+1){
answer(i, a[i]-(mini-1));
}
return;
}
a.clear();a.resize(n+1);
FOR(i,1,n){
if (type[i] == 1){
a[i+1] = a[i]-diff[i];
}else{
a[i+1] = a[i]+diff[i];
}
}
mini = 1e9; maxi = 0;
FOR(i,1,n+1){
mini = min(mini, a[i]);maxi = max(maxi, a[i]);
}
FOR(i,1,n+1){
answer(i, a[i]-(mini-1));
}
return;
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:22: error: 'n' was not declared in this scope
13 | vector<int> diff(n+1);
| ^
xylophone.cpp: At global scope:
xylophone.cpp:9:12: warning: 'A' defined but not used [-Wunused-variable]
9 | static int A[5000];
| ^