제출 #1332656

#제출 시각아이디문제언어결과실행 시간메모리
1332656hxanoWorm Worries (BOI18_worm)C++20
36 / 100
380 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;
   };

   while(1){
      if(f(x-1, y, z)) continue;
      if(f(x+1, y, z)) continue;
      if(f(x, y-1, z)) continue;
      if(f(x, y+1, z)) continue;
      if(f(x, y, z-1)) continue;
      if(f(x, y, z+1)) continue;

      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;
}
#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...