#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;
}
else{
vector<int> arr;
cout << arr[-1] << "\n";
}
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 |
0 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
OK (4 queries) |
2 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |