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 i64 = long long;
const int dx[6] = {-1, 1, 0, 0, 0, 0};
const int dy[6] = {0, 0, -1, 1, 0, 0};
const int dz[6] = {0, 0, 0, 0, 1, -1};
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m, k, q;
std::cin >> n >> m >> k >> q;
std::map<std::array<int, 3>, int> mp;
std::function<int(int, int, int)> query = [&](int x, int y, int z) {
if (x < 1 || x > n || y < 1 || y > m || z < 1 || z > k) {
return 0;
}
if (mp.count({x, y, z})) {
return mp[{x, y, z}];
}
std::cout << "? " << x << " " << y << " " << z << std::endl;
int v;
std::cin >> v;
mp[{x, y, z}] = v;
return v;
};
std::mt19937 rng(time(0));
std::function<void(int, int, int)> dfs = [&](int x, int y, int z) {
int p[6] = {0, 1, 2, 3, 4, 5};
std::shuffle(p, p + 6, rng);
for (int i = 0; i < 6; i++) {
if (query(x + dx[p[i]], y + dy[p[i]], z + dz[p[i]]) > query(x, y, z)) {
dfs(x + dx[p[i]], y + dy[p[i]], z + dz[p[i]]);
return;
}
}
std::cout << "! " << x << " " << y << " " << z << std::endl;
exit(0);
};
dfs((rng() % n) + 1, (rng() % m) + 1, (rng() % k) + 1);
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... |