Submission #648075

#TimeUsernameProblemLanguageResultExecution timeMemory
648075KenparGuess the number (BOI20_guess)C++17
100 / 100
1 ms296 KiB
//CSES grind baby #include "bits/stdc++.h" using namespace std; #define ll long long const ll MOD = 1e9+7; const ll INF = 1e16; const ll MAX = 2e5+1; int ask(int x){ int temp; cout<<"? "<<x<<endl; cin>>temp; return temp; } int bSearch(int l, int r){ if(r >= l){ int mid = (l+r)>>1; int ans = ask(mid); if(ans == 0){ return mid; }else if(ans > 0){ return bSearch(l, mid-1); } return bSearch(mid+1, r); }else{ cout<<1; } } void solve(){ int n; cin>>n; int ans = bSearch(1,n); cout<<"= "<<ans; } int main() { //cin.tie(NULL); //ios::sync_with_stdio(NULL); int t = 1; //cin >> t; while(t--){ solve(); cout<<endl; } }

Compilation message (stderr)

Guess.cpp: In function 'int bSearch(int, int)':
Guess.cpp:33:9: warning: control reaches end of non-void function [-Wreturn-type]
   33 |   cout<<1;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...