Submission #642265

#TimeUsernameProblemLanguageResultExecution timeMemory
642265KenparGuess the number (BOI20_guess)C++17
0 / 100
1 ms292 KiB
//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<<endl; 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(0,n); } int main() { int t = 1; //cin >> t; while(t--){ solve(); cout<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...