# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854210 | Trisanu_Das | Colors (BOI20_colors) | C++17 | 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;
#define int long long
bool query(int i) {
cout << "? " << i << '\n';
cin >> i;
return i;
}
int main() {
int N; cin >> N;
int i = 0, c = 0, l = 1, r = N, d = -1;
for(; l < r; d = -d) {
l = (l + r - 1) >> 1;
i = max(i, int(1) - (c += d * l++));
}
query(i);
l = 1, r = N, d = -1;
for(; l < r; d = -d) {
ll m = (l + r - 1) >> 1;
if(query(i += d * m)) r = m;
else l = m + 1;
}
cout << "= " << l << '\n';
}