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>
using namespace std;
#include "grader.h"
int n;
int rec(int l, int r, bool isl){ //l'ultima query e' stata fatta a sx -> quella dopo su dx
if(r-l==1){
if(isl){
if(Guess(r)==-1) return l;
return r;
}else{
if(Guess(l)==-1) return r;
return l;
}
}
int g;
if(isl) g=Guess(r);
else g=Guess(l);
if(g==0) return (l+r)/2;
if(isl){
if(g==1){
return rec((l+r)/2,r,0);
}
else{
Guess(l);
return rec(l,min(n,(l+r)/2),1);
}
}else{
if(g==-1){
Guess(r);
return rec((l+r)/2,r,0);
}
else {
return rec(l,min(n,(l+r)/2),1);
}
}
}
int HC(int N){
n=N;
Guess(1);
return rec(1,N,1);
}
# | 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... |