Submission #278774

#TimeUsernameProblemLanguageResultExecution timeMemory
278774evpipisWorm Worries (BOI18_worm)C++11
32 / 100
1 ms256 KiB
#include <bits/stdc++.h> using namespace std; int n, m, k, q; map<tuple<int, int, int>, int> mym; int ask(int a = 1, int b = 1, int c = 1){ if (a < 1 || b < 1 || c < 1 || a > n || b > m || c > k) return 0; if (mym.count(make_tuple(a, b, c))) return mym[make_tuple(a, b, c)]; printf("? %d %d %d\n", a, b, c), fflush(stdout); int ans; scanf("%d", &ans); if (ans == -1) exit(0); return mym[make_tuple(a, b, c)] = ans; } void solve_1D(){ int l = 1, r = n, m1, m2, keep = 0; while (l < r){ swap(m1, m2); if (keep != 1) m1 = ceil(0.62*l + 0.38*r); if (keep != 2) m2 = floor(0.38*l + 0.62*r); if (m1 > m2) swap(m1, m2); if (m1 == m2) (l < m1 ? m1-- : m2++); assert(m1 < m2); //printf("l = %d, r = %d\n", l, r); //printf("m1 = %d, m2 = %d\n", m1, m2); //assert(m1 < m2); //printf("%d vs %d\n", ask(m1), ask(m2)); if (ask(m1) >= ask(m2)) r = m2-1, keep = 2; else l = m1+1, keep = 1; } printf("! %d 1 1\n", l), fflush(stdout); } void solve_2D(){ } void solve_3D(){ } int main(){ scanf("%d %d %d %d", &n, &m, &k, &q); if (k > 1) solve_3D(); else if (m > 1) solve_2D(); else solve_1D(); return 0; }

Compilation message (stderr)

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