제출 #1093710

#제출 시각아이디문제언어결과실행 시간메모리
1093710MateiKing80Worm Worries (BOI18_worm)C++14
0 / 100
1207 ms18232 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 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) { shuffle(nv, nv + 6, rng); 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 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...