#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(69420);
int HC(int N){
int l=1, r=N;
while (l<=r){
int mid=(l+r)>>1;
if (l==r) return mid;
int m1=(l+r)>>1, m2=(l+r+1)>>1;
if (m1==m2) --m1, ++m2;
Guess(m1);
int t=Guess(m2);
if (!t) return mid;
if (r-l+1<=3){
if (t==1) return r;
return l;
}
if (r-l+1==4){
if (t==1){
if (Guess(r)==1) return r;
return r-1;
}else{
if (Guess(l)==1) return l;
return l+1;
}
}
if (r-l+1==5){
if (t==1){
if (Guess(r)==1) return r;
return r-1;
}else{
Guess(l+1);
if (Guess(l)==1) return l;
return l+1;
}
}
if (r-l+1==6){
if (t==1){
t=Guess(r);
return r-1+t;
}else{
t=Guess(l+1);
if (t==0) return l+2;
if (t==-1) return l+3;
if (Guess(l)==1) return l;
return l+1;
}
}
if (t==1){
l=m2;
int t=Guess(r);
mid=(l+r)>>1;
if (!t) return mid;
if (t==1) l=mid+1;
else r=mid;
}else{
r=m2;
int t=-Guess(l);
mid=(l+r)>>1;
if (!t) return mid;
if (t==1) l=mid+1, r=m1;
else r=mid;
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
399 ms |
8020 KB |
Output is partially correct - alpha = 0.500000000000 |