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;
typedef long long ll;
mt19937 rng(1557);
int HC(int N){
ll l = 1, r = N, p = -1;
while(l<r){
bool flagL = (p<=l && r+l-p<=N);
bool flagR = (p>=r && r+l-p>=1);
if (!flagL && !flagR){
if (r==N) p = l, Guess(p), flagL = true;
else if (l==1) p = r, Guess(p), flagR = true;
else if (rng()&1) p = l, Guess(p), flagL = true;
else p = r, Guess(p), flagR = true;
}
int ret;
if (flagL){
p = r+l-p, ret = Guess(p);
if (ret==0) return (l+r) / 2;
else if (ret==1) l = (l+r) / 2 + 1;
else r = (l+r-1) / 2;
}
else{
p = r+l-p, ret = Guess(p);
if (ret==0) return (l+r) / 2;
else if (ret==-1) l = (l+r) / 2 + 1;
else r = (l+r-1) / 2;
}
}
return l;
}
# | 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... |