Submission #1194966

#TimeUsernameProblemLanguageResultExecution timeMemory
1194966Valters07Worm Worries (BOI18_worm)C++20
32 / 100
0 ms436 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 ld gold = (3.0 - sqrt(5)) / 2.0; pair<int,int> dd[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 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; } bool is(int x, int y) { int cur = ask(x, y), mx = -1, t = -1; for(int d = 0;d < 4;d++) { int nwx = x + dd[d].fi, nwy = y + dd[d].se; if(ask(nwx, nwy) > mx) { mx = ask(nwx, nwy); t = d; } } return (cur >= mx); } int main() { fio // ifstream cin("in.in"); cin >> n >> m >> k >> q; if(max(m, k) == 1) { int l = 1, r = n; int lpos = 1 + floor(n * gold), rpos = n - floor(n * gold); while(l + 5 <= r) { int lval = ask(lpos), rval = ask(rpos); if(lval < rval) { l = lpos; lpos = rpos; int sz = r - l + 1; rpos = r - floor(sz * gold); } else { r = rpos; rpos = lpos; int sz = r - l + 1; lpos = l + floor(sz * gold); } } int mxpos = l; for(int i = l;i <= r;i++) if(ask(i) > ask(mxpos)) mxpos = i; guess(mxpos); } else if(k == 1) { int ln = 1, rn = n, lm = 1, rm = m; // } 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...