제출 #723557

#제출 시각아이디문제언어결과실행 시간메모리
723557MDSProWorm Worries (BOI18_worm)C++17
10 / 100
3 ms4176 KiB
#include <stdio.h> #include <stdlib.h> #include <vector> #include <random> #include <ctime> #include <iostream> std::mt19937 rnd(22); std::vector<int> kn; int qq = 0; 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; // ans = rand(); qq++; (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); // std::cerr << qq << '\n'; 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,m2 = (r+r+l)/3; if(query(l) > query(r)){ if(query(m2) <= query(l)) { r = m2; continue; } } else { if(query(m1) <= query(r)) { l = m1; continue; } } 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:16:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  (void)scanf("%d", &ans);
      |        ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:31:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  (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...