# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713174 | Aaryan1378 | Colors (BOI20_colors) | 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 solve(long long int left, long long int right) {
if(left >= right) {
cout << "=" << " " << left << endl;
return;
}
long long int mid = (left + right + 1) / 2;
cout << "?" << " " << mid << endl;
long long int ans;
cin >> ans;
if(ans == 1) {
solve(left, mid);
} else {
solve(mid + 1, right)
}
}
int main() {
//your code goes here
long long int n;
cin >> n;
solve(1, n);
return 0;
}