#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define int long long
using namespace std;
int query(int x){
cout <<"? "<<x<<endl;
int ans;
cin>>ans;
return ans;
}
signed main(){
//setIO("closing");
int n;
cin>>n;
int l=0;
int r=n;
int pos=1;
vector<int> tab;
while(r-l>1){
tab.pb((r+l)/2);
l=(r+l)/2;
}
for(auto u:tab)
pos+=(pos+u <= n ? u : -u);
map<int,bool> vis;
l=0;r=n;
vis[pos]=true;
query(pos);
while(r-l>1){
int mid=(r+l)/2;
if(pos+mid<=n&&!vis[pos+mid]){
pos+=mid;
}else pos-=mid;
vis[pos]=1;
if(query(pos)) r=mid;
else l=mid;
}
cout <<"= "<<r<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
OK (4 queries) |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |