Submission #743627

#TimeUsernameProblemLanguageResultExecution timeMemory
743627rahidilbayramliGuess the number (BOI20_guess)C++17
0 / 100
2547 ms208 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define pb push_back #define all(v) v.begin(), v.end() #define pii pair<int, int> #define pll pair<ll, ll> #define f first #define s second using namespace std; int main() { ll n; cin >> n; ll l = 1, r = n, ans = -1, mid; while(l <= r) { mid = (l + r) / 2; cout << "? " << mid << "\n"; cout << flush; string s; cin >> s; if(s == "-1") l = mid; if(s == "0") { cout << "= " << mid << "\n"; cout << flush; return 0; } else r = mid; } }

Compilation message (stderr)

Guess.cpp: In function 'int main()':
Guess.cpp:17:22: warning: unused variable 'ans' [-Wunused-variable]
   17 |     ll l = 1, r = n, ans = -1, mid;
      |                      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...