Submission #714500

#TimeUsernameProblemLanguageResultExecution timeMemory
714500MilosMilutinovicWorm Worries (BOI18_worm)C++14
0 / 100
1327 ms20752 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...