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<bits/stdc++.h>
using namespace std;
int Guess(int n);
// int Guess(int n){
// cout << "? " << n << ": ";
// int num;
// cin >> num;
// return num;
// }
int HC(int n){
int l = 1, r = n, last = 1;
Guess(1);
while(l < r){
int mid = (l + r) >> 1;
// cout << l << ", " << r << ": " << last << '\n';
if(last == l){
int num = Guess(r);
if(num == -1){
r = mid;
last = r;
Guess(r);
}
else if(num == 1){
l = mid + 1;
last = l;
Guess(l);
}
else{
return (l + r) >> 1;
}
}
else{
int num = Guess(l);
if(num == 1){
r = mid;
last = r;
Guess(r);
}
else if(num == -1){
l = mid + 1;
last = l;
Guess(l);
}
else return (l + r) >> 1;
}
}
return l;
}
// int main(){
// int n, X;
// cin >> n >> X;
// cout << HC(n);
// }
# | 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... |