# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
489748 | gabrupro | Colors (BOI20_colors) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
#define pb push_back
#define bg begin()
#define ed end()
#define fi for(int i=0;i<n;i++)
const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n;cin>>n;
ll l=1, r=n;
int qwe
cout<<"? "<<1<<endl;cin>>qwe;
bool done=false;
while(abs(r-l)>0){
cout<<"? "<<r<<endl;
int ans;cin>>ans;
int mid=(l+r)/2; int rd=r;
if(ans){r=mid;}
else{
if(r>l){r=l-mid;}
else{r=l+mid;}
}
l=rd;
if(abs(l-r)>n){cout<<"= "<<n<<endl;done=true;break}
}
if(!done){cout<<"= "<<l<<endl;}
}