#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
map <std::pair <int, int>, int> mp,mp2;
int HC(int N){
mp.clear();
mp2.clear();
int l=1,r=N,kq=N,val;
int last=N;
val=Guess(N);
while (l<r){
if (mp2.count({l,r})){
val=Guess((last<l?l:r));
last=(last<l?l:r);
}
mp2[{l,r}]=1;
int mid=l+r-last;
mid=std::max(mid,1);
mid=std::min(mid,N);
val=(mp.count({last,mid})?mp[{last,mid}]:Guess(mid));
int ch=(mp.count({last,mid}));
mp[{last,mid}]=val;
mp[{mid,last}]=-val;
if (val==0)
return (mid+last)/2;
if (val==1){
if (last<mid)
l=(last+mid+1)/2;
else{
r=(last+mid-1)/2;
kq=r;
}
if (!ch)
last=mid;
continue;
}
if (last<mid){
r=(last+mid-1)/2;
kq=r;
}
else
l=(last+mid+1)/2;
if (!ch)
last=mid;
}
return kq;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
263 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
263 ms |
1288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
9154 ms |
8108 KB |
Output is partially correct - alpha = 0.250000000000 |