Submission #500512

#TimeUsernameProblemLanguageResultExecution timeMemory
500512LittleCubeWorm Worries (BOI18_worm)C++14
10 / 100
1 ms328 KiB
#include <bits/stdc++.h> int arr[1000005]; int N, M, K, Q; int query(int x, int y, int z) { if (arr[x] == 0 && 1 <= x && x <= N) { printf("? %d %d %d\n", x, y, z); fflush(stdout); int ans = -1; (void)scanf("%d", &ans); if (ans == -1) exit(0); arr[x] = ans; } return arr[x]; } __attribute__((noreturn)) void guess(int x, int y, int z) { printf("! %d %d %d\n", x, y, z); exit(0); } const double phi = 0.618033988749894848204586; int main() { (void)scanf("%d %d %d %d", &N, &M, &K, &Q); if (M == 1 && K == 1) { int L = 1, R = N; while (R - L >= 3) { int lmid = round(phi * L + (1.0 - phi) * R), rmid = round((1.0 - phi) * L + phi * R); int lans = query(lmid, 1, 1), rans = query(rmid, 1, 1); if (lans >= rans) R = rmid - 1; else L = lmid + 1; } for (int i = L; i <= R; i++) if (query(i - 1, 1, 1) <= query(i, 1, 1) && query(i, 1, 1) >= query(i + 1, 1, 1)) guess(i, 1, 1); } } // 1 4 2 5 8 | 4 2 5 4 2

Compilation message (stderr)

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