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 "grader.h"
#include<bits/stdc++.h>
using namespace std;
int HC(int N){
if(N==1)return 1;
int l=1, r=N;
int lst, akt;
akt=(l+r+1)/2-1;
Guess(akt);
int x=1, y=3;
while(l<r){
//cout<<lst<<" "<<akt<<" "<<l<<" "<<r<<"\n";
lst=akt;
if(lst<l)akt=r-(r-l)*x/y;
else if(lst>r)akt=l+(r-l)*x/y;
else{
akt=l+r-lst;
if(lst-l<(r-l)/4)akt-=(r-l)/4;
if(r-lst<(r-l)/4)akt+=(r-l)/4;
if(akt==lst){
if(akt==l)akt++;
else akt--;
}
}
/*akt=(l+r+1)/2;
if(akt==lst)akt--;*/
int k=Guess(akt);
//cout<<lst<<" "<<akt<<" "<<l<<" "<<r<<"\n";
if(k==0)return (lst+akt)>>1;
if((akt<lst) ^ (k==1))l=max((lst+akt+2)/2, l);
else r=min(r, (lst+akt-1)/2);
}
return l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |