Submission #648072

#TimeUsernameProblemLanguageResultExecution timeMemory
648072KenparGuess the number (BOI20_guess)C++17
0 / 100
0 ms208 KiB
//CSES grind baby #include "bits/stdc++.h" using namespace std; #define endl '\n' #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; cout.flush(); 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:36:9: warning: control reaches end of non-void function [-Wreturn-type]
   36 |   cout<<1;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...