#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
long long n,i,j,ress[5005][5005],resp,neg,minn,maxx;
long long ans[5005];
long long res(long long x,long long y){
if (ress[x][y]!=0) return ress[x][y];
ress[x][y]=query(x,y);
return ress[x][y];
}
void solve(int n){
if (n==2){
cout<<"A 1 2"<<endl;
return 0;
}
ans[1]=0;
for (i=1;i<=n-2;i++){
if (res(i,i+1)+res(i+1,i+2)==res(i,i+2)){
ans[i+1]=ans[i]+res(i,i+1);
ans[i+2]=ans[i]+res(i,i+2);
if (ans[i+2]>=n){
ans[i+1]=ans[i]-res(i,i+1);
ans[i+2]=ans[i]-res(i,i+2);
}
}
else {
ans[i+1]=ans[i]+res(i,i+1);
ans[i+2]=ans[i+1]-res(i+1,i+2);
if (ans[i+1]>=n){
ans[i+1]=ans[i]-res(i,i+1);
ans[i+2]=ans[i+1]+res(i+1,i+2);
}
}
if (ans[i+2]<0 || ans[i+1]<0) neg=1;
}
maxx=1; minn=1;
for (i=2;i<=n;i++){
if (ans[i]>ans[maxx]) maxx=i;
if (ans[i]<ans[minn]) minn=i;
}
if (maxx<minn) {
for (i=1;i<=n;i++){
ans[i]=-ans[i];
}
}
minn=ans[1];
for (i=2;i<=n;i++){
minn=min(minn,ans[i]);
}
minn=-minn+1;
for (i=1;i<=n;i++) answer(i,ans[i]+minn);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
solve(n);
}
Compilation message
xylophone.cpp: In function 'long long int res(long long int, long long int)':
xylophone.cpp:9:13: error: 'query' was not declared in this scope
9 | ress[x][y]=query(x,y);
| ^~~~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:15:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
15 | return 0;
| ^
xylophone.cpp:52:21: error: 'answer' was not declared in this scope
52 | for (i=1;i<=n;i++) answer(i,ans[i]+minn);
| ^~~~~~