#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
auto question = [&](int col) {
cout << "? " << col << '\n';
fflush(stdout);
int x;
cin >> x;
fflush(stdout);
return x;
};
auto output = [&](int col) {
cout << "= " << col << '\n';
fflush(stdout);
};
question(1);
int lo = 0, hi = n - 1, ind = -1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
question(1);
if (question(mid + 1)) {
ind = mid;
lo = mid + 1;
} else {
hi = mid - 1;
}
}
if (ind == -1) {
output(n);
} else {
output(ind);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |