Submission #723743

#TimeUsernameProblemLanguageResultExecution timeMemory
723743Mr_HusanboyWorm Worries (BOI18_worm)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> using namespace std; int max_Q; int n, m, k; int cnt_q = 0; #ifdef LOCAL vector<vector<vector<int>>> mat; #endif int ask(int x, int y, int z) { printf("? %d %d %d\n", x, y, z); fflush(stdout); int ans = -1; #ifdef LOCAL cnt_q ++; if(x > n || y > m || z > k || cnt_q > max_Q){ ans = -1; }else{ ans = mat[x - 1][y - 1][z - 1]; } #else (void)scanf("%d", &ans); #endif 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); exit(0); } mt19937 mt(); void sub1(int &n){ int l = 1, r = n; while(l < r){ int m = (l + r) >> 1; if(l == r){ guess(l, 1, 1); } int h = ask(m + 1, 1, 1); int hh = ask(m, 1, 1); if(l == r - 1){ if(h > hh){ guess(m + 1, 1, 1); }else{ guess(m, 1, 1); } } if(h >= hh){ l = m + 1; }else{ r = m; } } } void solve(){ cin >> n >> m >> k; cin >> max_Q; #ifdef LOCAL mat.assign(n, vector(m, vector(k, 0))); for(int i = 0; i < n; i ++){ for(int j = 0; j < m; j ++){ for(int ii = 0; ii < k; ii ++){ cin >> mat[i][j][ii]; } } } #endif if(n <= 1000000){ sub1(n); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int testcases = 1; while(testcases --){ solve(); if(testcases) cout << '\n'; #ifdef LOCAL else cout << '\n'; cout << "__________________________" << endl; #endif } return 0; }

Compilation message (stderr)

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