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>
#include "xylophone.h"
using namespace std;
static int A[5000];
void solve(int N) {
int l=1,r=N,mid,i,mx=1,idx=0;
while(r>l){
mid=(r+l+1)/2;
if(query(mid,N)==N-1) l=mid;
else r=mid-1;
}
cout << l << "\n";
answer(l,1);
for(i=l+1;i<=N;i++){
int x=query(l,i),y;
if(x>=mx){
answer(i,x+1);
mx=x+1;
idx=i;
}
else{
y=query(idx,i);
answer(i,mx-y);
}
}
}
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... |