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){
// cout<<l<<" "<<r<<" "<<lst<<endl;
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 Tg=0;
int HC(int N){
Tg++;
n=N;
srand(Tg*5+41+(Tg<<1));
if(0){
Guess(1);
return fnd(1,n,1);
}
else{
Guess(n);
return fnd(1,n,n);
}
}
Compilation message (stderr)
hottercolder.cpp: In function 'int fnd(int, int, int)':
hottercolder.cpp:41:17: warning: unused variable 'a' [-Wunused-variable]
int a= Guess(r);
^
# | 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... |