#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,bool> used;
ll n;
bool good(ll mid, ll &cur){
if(cur + mid <= n && !used[cur + mid]){
cur += mid;
used[cur] = true;
cout << "? " << cur << endl;
bool a;cin >> a;
return a;
}
else if(cur - mid > 0 && !used[cur - mid]){
cur -= mid;
used[cur] = true;
cout << "? " << cur << endl;
bool a;cin >> a;
return a;
}
cout << "= " << 1e9 << endl;
return false;
}
signed main(){
cin >> n;
ll cur = 0;
good(1,cur);
ll l = 1,r = n;
while(l < r){
ll mid = (l + r)/2;
if(good(mid,cur)){
r = mid;
}
else{
l = mid + 1;
}
}
cout << "= "<< l << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Incorrect |
1 ms |
200 KB |
Expected integer, but "1e+09" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Incorrect |
1 ms |
200 KB |
Expected integer, but "1e+09" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Incorrect |
1 ms |
200 KB |
Expected integer, but "1e+09" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Incorrect |
1 ms |
200 KB |
Expected integer, but "1e+09" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
OK (4 queries) |
2 |
Incorrect |
1 ms |
200 KB |
Expected integer, but "1e+09" found |
3 |
Halted |
0 ms |
0 KB |
- |