This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Segment Tree Degil Bu What
#include "bits/stdc++.h"
using namespace std;
#define ll long long
const ll MOD = 1e9+7;
const ll MAX = 2e5+1;
void bSearch(int l, int r){
if(r>=l){
int mid = l + (r-l)/2;
int ans;
cout<<"? "<<mid<<'\n';
cout.flush();
cin>>ans;
if(ans == 0){
cout<<"= "<<mid;
return;
}else if(ans == -1){
return bSearch(l, mid-1);
}
return bSearch(mid+1, r);
}else{
//cout<<"Exception Occured, Wait what?";
}
}
void solve(){
int n;
cin>>n;
return bSearch(1,n);
}
int main()
{
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |