This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
if(n>125)
return 0;
if(n==1){
cout<<"= "<<1<<endl;
return 0;
}
bool r=0;
int mid=(n/2)+1;
cout<<"? "<<mid<<endl;
cin>>r;
cout<<"? "<<1<<endl;
cin>>r;
if(r==0){
r=1;
int a=1,b=n+1;
int i=0;
while((b-a)>mid){
if(i){
a++;
cout<<"? "<<a<<endl;
cin>>r;
if(r==0)
break;
}
else{
b--;
cout<<"? "<<b<<endl;
cin>>r;
if(r==0)
break;
}
i^=1;
}
cout<<"= "<<(b-a)+!r<<endl;
}
else{
int a=1,b=mid;
if(b==2){
cout<<"= "<<1<<endl;
return 0;
}
for(int i=2;i<mid;i++){
if(i%2){
a++;
cout<<"? "<<a<<endl;
cin>>r;
if(r==0)
break;
}
else{
b--;
cout<<"? "<<b<<endl;
cin>>r;
if(r==0)
break;
}
}
cout<<"= "<<(b-a)+!r<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |