Submission #1260030

#TimeUsernameProblemLanguageResultExecution timeMemory
1260030SzymonKrzywdaWorm Worries (BOI18_worm)C++20
10 / 100
14 ms508 KiB
#include <iostream> #include <map> using namespace std; map<int, int> queries; int ask(int x, int y = 1, int z = 1) { if (queries.find(x) != queries.end()) return queries[x]; cout << "? " << x << ' ' << y << ' ' << z << endl; cin >> queries[x]; return queries[x]; } int dx[] = {1, -1, 0, 0, 0, 0}; int dy[] = {0, 0, 1, -1, 0, 0}; int dz[] = {0, 0, 0, 0, 1, -1}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); srand(2137); int q, n, m, k; cin >> n >> m >> k >> q; int aktx = 0, akty = 0, aktz = 0, aktval = 0; for (int i = 0; i < q / 2; i++) { int x = rand() % n + 1, y = rand() % m + 1, z = rand() % k + 1; int val = ask(x, y, z); if (val > aktval) { aktx = x; akty = y; aktz = z; } aktval = max(val, aktval); } while (true) { int bestval = 0, bestoption = 0; for (int i = 0; i < 6; i++) { if (aktx + dx[i] < 1 || aktx + dx[i] > n || akty + dy[i] < 1 || akty + dy[i] > m || aktz + dz[i] < 1 || aktz + dz[i] > k) continue; int val = ask(aktx + dx[i], akty + dy[i], aktz + dz[i]); if (val > bestval) bestoption = i; bestval = max(val, bestval); } if (bestval <= aktval) { cout << "! " << aktx << ' ' << akty << ' ' << aktz << endl; return 0; } else { aktval = bestval; aktx += dx[bestoption]; akty += dy[bestoption]; aktz += dz[bestoption]; } } 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...