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 n;
int fq=0;
int fnd(int l,int r,int lst){
if(l==r)return l;
else if(r<l)return 1;
if(lst<=l){
int x=min(n,l-lst+r);
int md=(x+lst)/2;
if(md+1<=l){
int a;
if(lst==l){
a=Guess(l+1);
if(a>0)return fnd(l+1,r,l+1);
else return l;
}
a=Guess(l);
return fnd(l,r,l);
}
int c=Guess(x);
if(c==0)return (x+lst)/2;
if(c==1){
return fnd(max(md+1,l),r,x);
}
else{
return fnd(l,min(r,md),x);
}
}
else{
int x=max(1,l-(lst-r));
int md=(x+lst)/2;
if(md>=r){
if(lst==r){
int a=Guess(r-1);
if(a>0)return fnd(l,r-1,r-1);
else return r;
}
int a= Guess(r);
return fnd(l,r,r);
}
int c=Guess(x);
if(c==0)return (x+lst)/2;
if(c==1){
return fnd(l,min(r,md),x);
}
else{
return fnd(max(md+1,l),r,x);
}
}
}
int gti(int l,int r,int lst){
// cout<<l<<" "<<r<<" "<<lst<<endl;
if(l==r)return l;
else if(r<l)return 1;
int md=(l+r)/2;
// cout<<md<<endl;
int x=md+md-lst;
if(x<1){
Guess(l);
return gti(l,r,l);
}
else if(x>n){
Guess(r);
return gti(l,r,r);
}
if(x==lst)x++;
// cout<<x<<endl;
int pmid=(x+lst)/2;
int ok = Guess(x);
if(ok==0){
return pmid;
}
bool h=pmid>=lst;
h^=ok==1;
if(h==0){
return gti(pmid+1,r,x);
}
else{
return gti(l,pmid,x);
}
}
int Tg=0;
int HC(int N){
n=N;
int md=(1+N)/2;
Guess(1);
int x=Guess(md);
if(x==0){
return (1+md)/2;
}
int ps=(1+md)/2;
if(x==1){
gti(ps+1,n,md);
}
else gti(1,ps,md);
}
Compilation message (stderr)
hottercolder.cpp: In function 'int fnd(int, int, int)':
hottercolder.cpp:40:17: warning: unused variable 'a' [-Wunused-variable]
int a= Guess(r);
^
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:99:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |