#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
ll n,m,k,q;
map<ll,int> query_map;
int ask(int x, int y, int z)
{
if(x < 1 || x > n || y < 1 || y > m || z < 1 || z > k) return 0;
int h = x-1 + (y-1)*n + (z-1)*n*m;
if(query_map.find(h) != query_map.end()) return query_map[h];
cout << "? " << x << " " << y << " " << z << endl;
cin >> query_map[h];
return query_map[h];
}
pair<int,pii> find_sons(int x, int y, int z)
{
vector<pair<int,pii>> dir = {{0,{0,1}},{0,{0,-1}},{0,{1,0}},{0,{-1,0}},{1,{0,0}},{-1,{0,0}}};
int val = ask(x,y,z);
forall(it,dir)
{
int x2 = x+it.ff;
int y2 = y+it.ss.ff;
int z2 = z+it.ss.ss;
if(ask(x2,y2,z2) > val) return {x2,{y2,z2}};
}
return {-1,{-1,-1}};
}
int main()
{
cin >> n >> m >> k >> q;
random_start();
pair<int,pair<int,pii>> best = {-1,{-1,{-1,-1}}};
rep(i,q/3)
{
int x = los(1,n);
int y = los(1,m);
int z = los(1,k);
best = max(best,{ask(x,y,z),{x,{y,z}}});
}
int x = best.ss.ff;
int y = best.ss.ss.ff;
int z = best.ss.ss.ss;
while(true)
{
pair<int,pii> nxt = find_sons(x,y,z);
if(nxt.ff == -1) break;
x = nxt.ff;
y = nxt.ss.ff;
z = nxt.ss.ss;
}
cout << "! " << x << " " << y << " " << z << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |