Submission #357716

#TimeUsernameProblemLanguageResultExecution timeMemory
357716mjhmjh1104Colors (BOI20_colors)C++14
0 / 100
1 ms384 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<long long> v; long long n; int t; int main() { scanf("%lld", &n); long long curr = 1; long long l = n / 2, r = n - 1; while (l < r) { v.push_back(l); l = (l + r) / 2 + 1; } v.push_back(l); reverse(v.begin(), v.end()); for (auto &i: v) { if (curr + i <= n) curr += i; else curr -= i; } printf("? %lld\n", curr); fflush(stdout); scanf("%*d"); l = 0, r = n - 1; while (l < r) { long long m = (l + r) / 2; if (curr + m <= n) curr += m; else curr -= m; printf("? %lld\n", curr); fflush(stdout); scanf("%d", &t); if (t) r = m; else l = m + 1; } if (l == n - 1) { printf("? %lld\n", n); fflush(stdout); scanf("%d", &t); if (t) printf("= %lld\n", n - 1); else printf("= %lld\n", n); } else printf("= %lld\n", l); fflush(stdout); }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
Colors.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%*d");
      |     ~~~~~^~~~~~~
Colors.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
Colors.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...