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 HC(int N){
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int l = 1, r = N;
int lst = 1;
Guess(lst);
for(int i=0;i<100;i++) {
if(l == r) return l;
int curr = (l + r) / 2;
if(curr == lst) curr++;
int q = Guess(curr);
//cout<<i<<" - Previous was: "<<lst<<"\n";
//cout<<l<<", "<<r<<" - "<<curr<<" --> "<<q<<"\n";
if(curr < lst) {
if(q == -1) {
int sz = (lst - curr + 1) / 2;
int cl = lst - sz + 1;
int cr = N;
l = max(l,cl);
r = min(r,cr);
}
else if(q == 0) {
int mid = (lst + curr) / 2;
return mid;
}
else {
int sz = (lst - curr + 1) / 2;
int cl = 1;
int cr = curr + sz - 1;
l = max(l,cl);
r = min(r,cr);
}
}
else if(curr > lst) {
if(q == -1) {
int sz = (curr - lst + 1) / 2;
int cl = 1;
int cr = lst + sz - 1;
l = max(l,cl);
r = min(r,cr);
}
else if(q == 0) {
int mid = (lst + curr) / 2;
return mid;
}
else {
int sz = (curr - lst + 1) / 2;
int cl = curr - sz + 1;
int cr = N;
l = max(l,cl);
r = min(r,cr);
}
}
lst = curr;
}
return 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... |