# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895201 | Irate | Hotter Colder (IOI10_hottercolder) | C++14 | 0 ms | 0 KiB |
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){
// // 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 - 1;
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 - 1;
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);
// }