This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int) x.size()
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define ROF(i, a, b) for(int i=(b-1); i>=(a); i--)
#define F0R(i, n) FOR(i, 0, n)
#define R0F(i, n) ROF(i, 0, n)
#define trav(x, y) for(auto&x:y)
using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll, ll>;
using pli=pair<ll, int>;
using vi=vector<int>;
using vl=vector<ll>;
using vpii=vector<pii>;
template<class T> inline bool ckmin(T&a, const T&b) {return b<a?a=b,1:0;}
template<class T> inline bool ckmax(T&a, const T&b) {return b>a?a=b,1:0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl='\n';
const int mxN=2e5+10;
const int MOD=1e9+7;
const ll infLL=1e18;
const ld eps=1e-6;
int n, m, k, q;
vector<vector<vi>> vis;
int query(int N, int M=0, int K=0){
if(N<0||M<0||K<0||N>=n||M>=m||K>=k) return 0;
if(vis[N][M][K]!=-1) return vis[N][M][K];
cout << "? " << N+1 << ' ' << M+1 << ' ' << K+1 << endl;
cin >> vis[N][M][K]; return vis[N][M][K];
}
int answer(int N, int M=0, int K=0){
cout << "! " << N+1 << ' ' << M+1 << ' ' << K+1 << endl;
exit(0);
}
void solve1(){
int l=0, r=n-1, m1=-1, m2=-1, lst=0;
while(l<r){
swap(m1, m2);
if(lst!=1)
m1=ceil(0.62*l+0.38*r);
if(lst!=2)
m2=floor(0.38*l+0.62*r);
if(m1>m2) swap(m1, m2);
if(m1==m2) {
if(m1>l) m1--; else m2++;
}
assert(m1<m2);
if(query(m1)>=query(m2)){
r=m2-1; lst=2;
}
else{
l=m1+1, lst=1;
}
// we have [l, m1, m2, r]
// we then go too [l, m2, m1, m2-1]
// [l, c, m1, m2-1]
}
answer(l);
}
void solve2(){
}
void solve3(){
}
int32_t main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> k >> q;
vis=vector<vector<vi>>(n, vector<vi>(m, vi(k, -1)));
if(m==1&&k==1) solve1();
else if(k==1) solve2();
else solve3();
}
# | 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... |