#include<bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
int a[5005], n;
int p1[5005], p2[5005];
bool thu(int u, int v){
if(v < 1 || v > n) return false;
a[1] = u, a[2] = v;
for(int i = 3; i <= n; i++){
if(a[i-2] > a[i-1]){
if(p2[i]==max(p1[i],abs(a[i-2]-a[i-1]))){
a[i] = a[i-1] + d1;
}
else if(p2[i]==p1[i]+abs(a[i-2]-a[i-1])){
a[i] = a[i-1] - d1;
}
return false;
}
else{
if(p2[i]==max(p1[i],abs(a[i-2]-a[i-1]))){
a[i] = a[i-1] - d1;
}
else if(p2[i]==p1[i]+abs(a[i-2]-a[i-1])){
a[i] = a[i-1] + d1;
}
else return false;
}
}
vector<bool> ch(n, false);
for(int i = 1; i <= n; i++){
if(a[i] < 1 || a[i] > n) return false;
if(ch[a[i]-1]) return false;
ch[a[i]-1] = true;
}
return true;
}
void solve(int m){
n = m;
int d = query(1, 2);
for(int i = 3; i <= n; i++){
p1[i] = query(i-1, i), p2[i] = query(i-2, i);
}
for(int v1 = 1; v1 <= n; v1++){
for(int z = -d; z <= d; z+=2*d){
if(thu(v1, v1+z)){
for(int i = 1; i <= n; i++) answer(i, a[i]);
return ;
}
}
}
}
Compilation message
xylophone.cpp: In function 'bool thu(int, int)':
xylophone.cpp:17:33: error: 'd1' was not declared in this scope; did you mean 'p1'?
17 | a[i] = a[i-1] + d1;
| ^~
| p1
xylophone.cpp:20:32: error: 'd1' was not declared in this scope; did you mean 'p1'?
20 | a[i] = a[i-1] - d1;
| ^~
| p1
xylophone.cpp:26:33: error: 'd1' was not declared in this scope; did you mean 'p1'?
26 | a[i] = a[i-1] - d1;
| ^~
| p1
xylophone.cpp:29:32: error: 'd1' was not declared in this scope; did you mean 'p1'?
29 | a[i] = a[i-1] + d1;
| ^~
| p1