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>
#define eb emplace_back
#define mt make_tuple
#define mp make_pair
#define F first
#define S second
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int MAX = 1e9;
int n, m, k;
map<tiii, int> _qry;
int cnt = 0;
int query(int x, int y, int z){
if(x <= 0 || x > n || y <= 0 || y > m || z <= 0 || z > k) return 0;
if(_qry.find(mt(x, y, z)) == _qry.end()){
cout << "? " << x << " " << y << " " << z << "\n" << flush;
int r = 0;
cin >> r;
if(r == -1) exit(0);
_qry[mt(x, y, z)] = r;
cnt++;
}
return _qry[mt(x, y, z)];
}
int findmx1(int y, int z){
int x = -1, mx = -1;
for(int i = 1; i <= n; i++){
int tmp = query(i, y, z);
if(tmp > mx) mx = tmp, x = i;
}
return x;
}
pii findmx2(int z){
int x = -1, y = -1, mx = -1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
int tmp = query(i, j, z);
if(tmp > mx) mx = tmp, x = i, y = j;
}
}
return mp(x, y);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> n >> m >> k >> q;
int x = -1, y = 1, z = 1;
int l = 1, r = n;
while(r - l > 3){
int m1 = (l * 2 + r) / 3;
int m2 = (l + r * 2) / 3;
if(query(m1, y, z) > query(m2, y, z)) r = m2;
else l = m1;
}
int mx = 0;
for(int i = l; i <= r; i++){
int tmp = query(i, y, z);
if(tmp > mx) mx = tmp, x = i;
}
cout << "! " << x << " " << y << " " << z << "\n" << flush;
return 0;
}
# | 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... |