#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;
ld c = (3-(ld)sqrt(5))/(ld)2;
ll n,m,k,q;
map<ll,int> query_map;
int ask(int x)
{
int y = 1;
int z = 1;
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];
}
void solve(int l, int r, int q1, int q2)
{
if(q1 == q2)
{
q1++;
if(q1 > r) q1-=2;
}
if(q1 > q2) swap(q1,q2);
if(r-l+1 <= 2)
{
rep2(i,l,r)
{
if(ask(i) >= ask(i-1) && ask(i) >= ask(i+1))
{
cout << "! " << i << " 1 1\n";
return;
}
}
}
int v1 = ask(q1);
int v2 = ask(q2);
if(v1 > v2)
{
solve(l,q2-1,q1,l+(ld)(r-l+1)*c);
}
else
{
solve(q1+1,r,q2,min((ld)r,r-(ld)(r-l+1)*c+1));
}
}
int main()
{
cin >> n >> m >> k >> q;
ll l = (ld)n*c;
ll r = min((ld)n,n-(ld)n*c+1);
// cout << l << " " << r << " " << (ld)n*c << " " << c << " lr\n";
solve(1,n,l,r);
};
# | 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... |