제출 #450401

#제출 시각아이디문제언어결과실행 시간메모리
450401nonsensenonsense1Worm Worries (BOI18_worm)C++17
0 / 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) { x = (13 * l + 8 * r) / 21; xval = query(x); } if (y == -1 || y > r || y <= x) { 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\n", l); return 0; }

컴파일 시 표준 에러 (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...