#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(l);
last=l;
}
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 |
234 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
1300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
234 ms |
1284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
8597 ms |
8492 KB |
Output is partially correct - alpha = 0.250000000000 |