Submission #1194422

#TimeUsernameProblemLanguageResultExecution timeMemory
1194422Valters07Worm Worries (BOI18_worm)C++20
10 / 100
12 ms684 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define ld long double #define en exit(0); #define pb push_back #define fi first #define se second using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int dx[] = {0, 0, 1, -1}; const int dy[] = {-1, 1, 0, 0}; map<array<int, 3>, int> mp; int n, m, k, q; int ask(int x, int y = 1, int z = 1) { if(min({x, y, z}) < 1 || x > n || y > m || z > k) return 0; array<int, 3> tmp = {x, y, z}; if(mp.count(tmp)) return mp[tmp]; cout << "? " << x << " " << y << " " << z << endl; int h; cin >> h; assert(q-- != 0); if(h == -1) exit(0); return mp[tmp] = h; } void guess(int x, int y = 1, int z = 1) { cout << "! " << x << " " << y << " " << z << endl; } int is(int x, int y) { int cur = ask(x, y); for(int d = 0;d < 4;d++) { int nwx = x + dx[d], nwy = y + dy[d]; if(ask(nwx, nwy) > cur) return d; } return -1; } int main() { fio // ifstream cin("in.in"); cin >> n >> m >> k >> q; if(max(m, k) == 1) { int l = 1, r = n; while(l < r) { int mid = (l + r) / 2; int vm = ask(mid), vm1 = ask(mid + 1); if(vm < vm1) l = mid + 1; else r = mid; } guess(l); } else if(k == 1) { int x = rng() % n + 1, y = rng() % m + 1; while(is(x, y) != -1) { int t = is(x, y); x += dx[t]; y += dy[t]; } guess(x, y); } 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...