Submission #357712

#TimeUsernameProblemLanguageResultExecution timeMemory
357712mjhmjh1104Colors (BOI20_colors)C++14
Compilation error
0 ms0 KiB
#include <cstdio> #include <vector> using namespace std; vector<int> v; int n, t; int main() { scanf("%d", &n); int curr = 1; int 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("? %d\n", curr); fflush(stdout); scanf("%*d"); l = 0, r = n - 1; while (l < r) { int m = (l + r) / 2; if (curr + m <= n) curr += m; else curr -= m; printf("? %d\n", curr); fflush(stdout); scanf("%d", &t); if (t) r = m; else l = m + 1; } if (l == n - 1) { printf("? %d\n", n); fflush(stdout); scanf("%d", &t); if (t) printf("= %d\n", n - 1); else printf("= %d\n", n); } else printf("= %d\n", l); fflush(stdout); }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:18:5: error: 'reverse' was not declared in this scope
   18 |     reverse(v.begin(), v.end());
      |     ^~~~~~~
Colors.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Colors.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%*d");
      |     ~~~~~^~~~~~~
Colors.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
Colors.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~