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;
typedef long double ld;
typedef unsigned long long ull;
ll l,r,res,ans;
void calc(ll lst){
// cout << l << ' ' << r << endl;
if(l >= r){
ans = l;
return;
}
ll md1 = l + (r - l) / 3;
ll md2 = r - (r - l) / 3;
if(abs(md1 - lst) < abs(md2 - lst))
swap(md1,md2);
res = Guess(md1);
if(res == 1){
if(lst > md1){
r = min(r,(md1+lst)/2);
}else{
l = max(l,(md1+lst)/2+1);
}
}else if(res == -1){
if(lst > md1){
l = max(l,(md1+lst)/2+1);
}else{
r = min(r,(md1+lst)/2);
}
}else{
ans = (md1+lst)/2;
return;
}
calc(md1);
}
int HC(int N){
l = 1;
r = N;
ll md1 = l + (r - l) / 3;
Guess(md1);
calc(md1);
return ans;
}
# | 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... |