Submission #450405

#TimeUsernameProblemLanguageResultExecution timeMemory
450405nonsensenonsense1Worm Worries (BOI18_worm)C++17
10 / 100
1 ms200 KiB
#include <cstdio> #include <cassert> int n, m, k, q; int query(int x) { printf("? %d 1 1\n", x); fflush(stdout); scanf("%d", &x); return x; } int main() { scanf("%d%d%d%d", &n, &m, &k, &q); int l = 1, r = n, x = -1, xval, y = -1, yval; while (l < r) { if (x == -1 || x < l || x >= (8 * l + 13 * r - 1) / 21 + 1 || r - l <= 40) { x = (13 * l + 8 * r) / 21; xval = query(x); } if (y == -1 || y > r || y <= x || r - l <= 40) { y = (8 * l + 13 * r - 1) / 21 + 1; yval = query(y); } assert(x < y); assert(x >= l); assert(y <= r); if (xval > yval) { r = y - 1; y = x; yval = xval; x = -1; } else { l = x + 1; x = y; xval = yval; y = -1; } } printf("! %d 1 1\n", l); return 0; }

Compilation message (stderr)

worm.cpp: In function 'int query(int)':
worm.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &x);
      |  ~~~~~^~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d%d%d%d", &n, &m, &k, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
worm.cpp:30:3: warning: 'yval' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |   if (xval > yval) {
      |   ^~
worm.cpp:30:3: warning: 'xval' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...