#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int query(ll a){
cout<<"? "<<a<<endl;
int b;
cin>>b;
return b;
}
void answer(ll a){
cout<<"= "<<a<<endl;
exit(0);
}
int main(){
int N;
cin>>N;
int ans=query(N/2);
ans=query(1);
if(ans==1){
ans=query(N/2-1);
if(ans==0)answer(N/2-1);
int last=N/2-2;
for(int i=2,j=N/2-2;last>1;i++,j--){
ans=query(i);
if(ans==0)answer(last);
last--;
if(last<=1)break;
ans=query(j);
if(ans==0)answer(last);
last--;
}
answer(1);
}
else{
ans=query(N);
if(ans==0)answer(N);
int last=N-1;
for(int i=2,j=N-1;last>N/2+1;i++,j--){
cout<<last<<endl;
ans=query(i);
if(ans==0)answer(last);
last--;
if(last<=N/2+1)break;
cout<<last<<endl;
ans=query(j);
if(ans==0)answer(last);
last--;
}
answer(N/2+1);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |