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 "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int A[5000];
void solve(int n) {
if(n==2){
answer(1,1);
answer(2,n);
return;
}
int a[5005],b[5005],c[5005];
for(int i=1;i<n;i++){
a[i]=query(i,i+1);
}
int val=query(1,3);
if(val==a[1]+a[2]){
b[1]=1;
b[2]=1;
}
else{
b[1]=1;
b[2]=-1;
}
for(int i=2;i<n-1;i++){
int val=query(i,i+2);
if(val==a[i]+a[i+1]){
if(b[i]==1) b[i+1]=1;
else b[i+1]=-1;
}
else{
if(b[i]==1) b[i+1]=-1;
else b[i+1]=1;
}
}
c[1]=0;
for(int i=2;i<=n;i++){
c[i]=c[i-1]+a[i]*b[i];
}
pair<int,int>mx={-(n+1),-1},mn={n+1,-1};
for(int i=1;i<=n;i++){
mx=max(mx,{c[i],i});
mn=min(mn,{c[i],i});
}
if(mx.second<mn.second){
for(int i=1;i<=n;i++){
c[i]=-c[i];
}
}
int ihesgegch=1-mn.first;
for(int i=1;i<=n;i++){
answer(i,c[i]+ihesgegch);
}
}
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... |