제출 #723544

#제출 시각아이디문제언어결과실행 시간메모리
723544MDSProWorm Worries (BOI18_worm)C++17
10 / 100
3 ms4176 KiB
#include <stdio.h> #include <stdlib.h> #include <vector> std::vector<int> kn; int query(int x, int y = 1, int z = 1) { if(kn[x] != 0) return kn[x]; printf("? %d %d %d\n", x, y, z); fflush(stdout); int ans = -1; (void)scanf("%d", &ans); if (ans == -1) exit(0); return kn[x] = ans; } __attribute__((noreturn)) void guess(int x, int y = 1, int z = 1) { printf("! %d %d %d\n", x, y, z); exit(0); } int main() { int N, M, K, Q; (void)scanf("%d %d %d %d", &N, &M, &K, &Q); kn.resize(N+1); int l = 1, r = N; while(r-l > 2){ int m1 = (r+l+l)/3; int m2 = (r+r+l)/3; if(query(m1) < query(m2)) l = m1; else r = m2; } int mx = l; for(int i = l+1; i <= r; ++i) if(query(i) > query(mx)) mx = i; guess(mx); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

worm.cpp: In function 'int query(int, int, int)':
worm.cpp:11:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  (void)scanf("%d", &ans);
      |        ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:25:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  (void)scanf("%d %d %d %d", &N, &M, &K, &Q);
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...