Submission #1332670

#TimeUsernameProblemLanguageResultExecution timeMemory
1332670hxanoWorm Worries (BOI18_worm)C++20
0 / 100
3077 ms440 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)2e18
#define _ <<' '<<
#define nl endl

mt19937_64 rng(random_device{}());

int rint(int x){
   return uniform_int_distribution<int>(1, x)(rng);
}

void solve(){
   int n, m, k, q;
   cin>>n>>m>>k>>q;

   auto qry = [&](int x, int y, int z){
      if(x < 1 or x > n or y < 1 or y > m or z < 1 or z > k) return 0ll;

      cout<<"?" _ x _ y _ z<<nl;

      cin>>x;
      return x;
   };

   int cur = 0, x, y, z;
   
   for(int i = 0; i < 1999; i++){
      int qx = rint(n), qy = rint(m), qz = rint(k);
      int qh = qry(qx, qy, qz);

      if(cur < qh){
         cur = qh;
         x = qx;
         y = qy;
         z = qz;
      }
   }

   auto f = [&](int nx, int ny, int nz){
      int qh = qry(nx, ny, nz);
      if(cur >= qh) return false;

      cur = qh;
      x = nx;
      y = ny;
      z = nz;
      return true;
   };

   vector<int> steps = {1, 2, 3, 4, 5, 6};
   while(1){
      random_shuffle(steps.begin(), steps.end());
      bool ok = 0;
      for (int t: steps){
        if(t == 1) {if(x-1, y, z) ok = 1;}
        if(t == 2) {if(x+1, y, z) ok = 1;}
        if(t == 3) {if(x, y-1, z) ok = 1;}
        if(t == 4) {if(x, y+1, z) ok = 1;}
        if(t == 5) {if(x, y, z-1) ok = 1;}
        if(t == 6) {if(x, y, z+1) ok = 1;}
      }
      if(!ok) {
        cout<<"!" _ x _ y _ z<<nl;
        return;
      }
    }
}

signed main(){
   ios_base::sync_with_stdio(0);
   cin.tie(NULL);cout.tie(NULL);

   int t = 1;
   //cin>>t;
   while(t--) solve();

   return 0;
}

Compilation message (stderr)

worm.cpp: In function 'void solve()':
worm.cpp:54:21: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   54 |       random_shuffle(steps.begin(), steps.end());
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from worm.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
#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...