#include <bits/stdc++.h>
using namespace std;
int Ask(int64_t num){
cout << "? " << num << endl;
int x;
cin >> x;
return x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int64_t n;
cin >> n;
int64_t l = 1, r = n-1, start = n, cur = 0, dir = 1;
while(l <= r){
int64_t mid = (l + r) / 2;
cur += dir*mid;
dir *= -1;
start = min(start, n - cur);
l = mid + 1;
}
l = 1, r = n-1, dir = 1;
int64_t answer = n-1;
Ask(start);
while(l <= r){
int64_t mid = (l + r) / 2;
int64_t ask = start + dir*mid;
dir *= -1;
if(Ask(ask)){
answer = mid;
r = mid - 1;
}
else l = mid + 1;
start = ask;
}
cout << "= " << answer << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
9 |
Correct |
1 ms |
204 KB |
OK (7 queries) |
10 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
11 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
12 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
13 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
14 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
16 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
17 |
Incorrect |
1 ms |
200 KB |
Wrong guess |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
9 |
Correct |
1 ms |
204 KB |
OK (7 queries) |
10 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
11 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
12 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
13 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
14 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
16 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
17 |
Incorrect |
1 ms |
200 KB |
Wrong guess |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
9 |
Correct |
1 ms |
204 KB |
OK (7 queries) |
10 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
11 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
12 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
13 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
14 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
16 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
17 |
Incorrect |
1 ms |
200 KB |
Wrong guess |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
9 |
Correct |
1 ms |
204 KB |
OK (7 queries) |
10 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
11 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
12 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
13 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
14 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
16 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
17 |
Incorrect |
1 ms |
200 KB |
Wrong guess |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
9 |
Correct |
1 ms |
204 KB |
OK (7 queries) |
10 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
11 |
Correct |
1 ms |
200 KB |
OK (5 queries) |
12 |
Correct |
1 ms |
200 KB |
OK (6 queries) |
13 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
14 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
16 |
Correct |
1 ms |
200 KB |
OK (7 queries) |
17 |
Incorrect |
1 ms |
200 KB |
Wrong guess |
18 |
Halted |
0 ms |
0 KB |
- |