This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
static int A[5000];
int sv[5010][5010],CC=0;
int query(int,int);
void answer(int,int);
void solve(int);
int myqry(int l,int r){
if(l>r)swap(l,r);
if(l==r)return 0;
if(sv[l][r])return sv[l][r];
assert(++CC<=10000);
return sv[l][r]=query(l,r);
}
int ans[5010];
int makesense(int a,int b,int c,int ac){
return ac==max({a,b,c})-min({a,b,c});
}
void solve(int N) {
ans[2]=myqry(1,2);
for(int i=3;i<=N;i++){
int k=myqry(i-1,i);
int c=myqry(i-2,i);
if(makesense(ans[i-1]-k,ans[i-1],ans[i-2],c))
ans[i]=ans[i-1]-k;
else ans[i]=ans[i-1]+k;
}
int d=min_element(ans+1,ans+N+1)-max_element(ans+1,ans+N+1);
if(d>0)
for(int i=1;i<=N;i++)
ans[i]=-ans[i];
int c=*min_element(ans,ans+N);
for(int i=1;i<=N;i++)
answer(i,ans[i]-c+1);
}
Compilation message (stderr)
xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
4 | static int A[5000];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |