제출 #724244

#제출 시각아이디문제언어결과실행 시간메모리
724244drdilyorWorm Worries (BOI18_worm)C++17
0 / 100
3063 ms4176 KiB
#include<bits/stdc++.h> using namespace std; int arr[100]; int query(int x, int y, int z) { printf("? %d %d %d\n", x, y, z); fflush(stdout); #ifdef ONPC return arr[x]; #endif int ans = -1; (void)scanf("%d", &ans); if (ans == -1) exit(0); return ans; } __attribute__((noreturn)) void guess(int x, int y, int z) { printf("! %d %d %d\n", x, y, z); #ifdef ONPC printf("[%d %d %d]", arr[x-1], arr[x], arr[x+1]); fflush(stdout); if (!(arr[x-1] <= arr[x] && arr[x] >= arr[x+1])) { for (int i = 1; i <= 15 ;i++) cout << arr[i] << ' '; cout << endl; assert(false); } #endif exit(0); } int main() { mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int N, M, K, Q; (void)scanf("%d %d %d %d", &N, &M, &K, &Q); assert(M == 1 && K == 1); #ifdef ONPC for (int i = 1; i <= N; i++) arr[i] = rng() % 100 + 1; #endif vector<int> cache(N+1); auto ask = [&](int x) { if (cache[x]) return cache[x]; return cache[x] = query(x, 1, 1); }; if (N == 1) { guess(1, 1, 1); } int l = 1, r = N; while (l < r) { int a = (l+l+r) / 3; int b = (l+r+r+2) / 3; if (ask(a) <= ask(b)) { l = a; } else r = a; } for (int i : {l, r}) if (ask(i) >= ask(i+1) && ask(i) >= ask(i-1)) guess(i, 1, 1); }

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

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