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 <algorithm>
using namespace std;
static int A[5000];
void solve(int N) {
int A[5000];
A[0]=0;
A[1]=query(1, 2);
for(int i=3; i<=N; i++){
int rec1=query(i-1, i);
int a=A[i-2]+rec1, b=A[i-2]-rec1;
if(a==A[i-3]){
A[i-1]=b;
continue;
}
if(b==A[i-3]){
A[i-1]=a;
continue;
}
int rec2=query(i-2, i);
if(A[i-3]<A[i-2]){
A[i-1]=rec2==a-A[i-3]?a:b;
}else{
A[i-1]=rec2==A[i-3]-b?b:a;
}
}
int mi=*min_element(A, A+N);
for(int i=N; i--;)
A[i]=A[i]-mi+1;
if(find(A, A+N, 1)-A>find(A, A+N, N)-A){
for(int i=N; i--;)
A[i]=N+1-A[i];
}
for(int i=0; i<N; i++)
answer(i+1, A[i]);
}
Compilation message (stderr)
xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
5 | 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... |