Submission #331671

#TimeUsernameProblemLanguageResultExecution timeMemory
331671VictorGuess the number (BOI20_guess)C++17
100 / 100
69 ms512 KiB
#include <bits/stdc++.h> using namespace std; #define ii pair<int, int> #define iii pair<int, ii> #define vi vector<int> #define vii vector<ii> #define ll long long #define INF 1000000000 int main() { int low = 1, high, response; scanf("%d", &high); do { int middle = (high + low) / 2; printf("? %d\n", middle); fflush(NULL); scanf("%d", &response); if (response > 0) high = middle - 1; else if (response < 0) low = middle + 1; } while (response); printf("= %d\n", (high + low) / 2); return 0; }

Compilation message (stderr)

Guess.cpp: In function 'int main()':
Guess.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     scanf("%d", &high);
      |     ~~~~~^~~~~~~~~~~~~
Guess.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |         scanf("%d", &response);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...