Submission #1127613

#TimeUsernameProblemLanguageResultExecution timeMemory
1127613LudisseyWorm Worries (BOI18_worm)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() using namespace std; vector<int> a; map<pair<int,pair<int,int>>,int> req; int n,m,k,q; void give_ans(int x, int y, int z){ cout << "! " << x+1 << " " << y+1 << " " << z+1 << endl; return; } int ask(int x, int y, int z){ if(req.find({x,{y,z}})!=req.end()) return req[{x,{y,z}}]; if(x<0||x>=n||y<0||y>=m||z<0||z>=k) return -1e9; cout << "? " << x+1 << " " << y+1 << " " << z+1 << endl; int ans; cin>>ans; req[{x,{y,z}}]=ans; return ans; } pair<int,pair<int,int>> grid_max(int z){ int mx=0; pair<int,int> mxI; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { int a=ask(j,i,z); if(mx<a){ mx=max(a,mx); mxI={j,i}; } } } return {mx,mxI}; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k >> q; int l=0; int r=k-1; int ans=0; int midc=grid_max((l+r+1)/2).second; int midl=grid_max((l+r+1)/2-1).second; if(midc<midl){ ans=(l+r+1)/2-1; r=(l+r+1)/2-1; }else{ ans=(l+r+1)/2-1; l=(l+r+1)/2; } while(l<r){ int mid=(l+r+1)/2; int midANS=grid_max(mid).first; int midANS2=grid_max(mid).second; if(midANS>=midANS2){ ans=mid; l=mid; }else{ r=mid-1; ans=mid-1; } } give_ans(grid_max(ans).second.first,grid_max(ans).second.second,ans); return 0; }

Compilation message (stderr)

worm.cpp: In function 'int main()':
worm.cpp:45:34: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   45 |     int midc=grid_max((l+r+1)/2).second;
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                  |
      |                                  std::pair<int, int>
worm.cpp:46:36: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   46 |     int midl=grid_max((l+r+1)/2-1).second;
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                    |
      |                                    std::pair<int, int>
worm.cpp:57:35: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   57 |         int midANS2=grid_max(mid).second;
      |                     ~~~~~~~~~~~~~~^~~~~~
      |                                   |
      |                                   std::pair<int, int>