Submission #648074

#TimeUsernameProblemLanguageResultExecution timeMemory
648074KenparGuess the number (BOI20_guess)C++17
Compilation error
0 ms0 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 ask(int)':
Guess.cpp:13:12: error: expected primary-expression before '<<' token
   13 |  cout<<""? <<x<<endl;
      |            ^~
Guess.cpp:13:21: error: expected ':' before ';' token
   13 |  cout<<""? <<x<<endl;
      |                     ^
      |                     :
Guess.cpp:13:21: error: expected primary-expression before ';' token
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;
      |         ^