Submission #124366

#TimeUsernameProblemLanguageResultExecution timeMemory
124366SOIVIEONEWorm Worries (BOI18_worm)C++14
0 / 100
3 ms380 KiB
#include <stdio.h> #include <stdlib.h> #include <map> #include <iostream> using namespace std; #define deb(x) cerr << #x << " = " << x << '\n' map<int, int> mp; int query(int x, int y, int z) { if(mp.count(x)) return mp[x]; printf("? %d %d %d\n", x, y, z); fflush(stdout); int ans = -1; (void)scanf("%d", &ans); if (ans == -1) exit(0); return mp[x] = ans; } __attribute__((noreturn)) void guess(int x, int y, int z) { 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); int l = 1, r = N; for(int i = 1; i <= 18; i ++) { int ml = (l + l + r) / 3; int mr = (l + r + r) / 3; int fl = query(ml, 1, 1), fr = query(mr, 1, 1); if(fl < fr) { l = ml; } else r = mr; } int loo = query(l, 1, 1), roo = query(r, 1, 1), moo = query((l+r)/2, 1, 1); int ans = 0; if(moo > loo && moo > roo && r - l > 1) ans = (l + r ) / 2; else if(loo > roo) ans = l; else ans = r; // deb(l); // deb(loo); // deb(r); // deb(roo); guess(ans, 1, 1); }

Compilation message (stderr)

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