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;
struct cell
{
int x, y, z;
};
bool operator <(cell a, cell b)
{
if(a.x != b.x)
return a.x < b.x;
if(a.y != b.y)
return a.y < b.y;
return a.z < b.z;
}
cell operator +(cell a, cell b)
{
return {a.x + b.x, a.y + b.y, a.z + b.z};
}
cell nv[6] = {{0, 0, 1}, {0, 0, -1}, {0, 1, 0}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0}};
map<cell, int> mp;
int n, m, k, q;
int ask(cell x)
{
if(x.x <= 0 || x.x > n || x.y <= 0 || x.y > m || x.z <= 0 || x.z > k)
return 0;
if(mp[x] != 0)
return mp[x];
if(q == 0)
exit(0);
q --;
cout << "? " << x.x << " " << x.y << " " << x.z << endl;
int ans = 0;
cin >> ans;
mp[x] = ans;
return ans;
}
void respond(cell x)
{
cout << "! " << x.x << " " << x.y << " " << x.z << endl;
exit(0);
}
void dfs(cell x)
{
random_shuffle(nv, nv + 6);
for(int i = 0; i < 6; i ++)
if(ask(x) < ask(nv[i] + x))
dfs(nv[i] + x);
respond(x);
}
int main()
{
cin >> n >> m >> k >> q;
cell x = {(n + 1) / 2, (m + 1) / 2, (k + 1) / 2};
dfs(x);
}
# | 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... |