Submission #311238

#TimeUsernameProblemLanguageResultExecution timeMemory
311238OttoTheDinoWorm Worries (BOI18_worm)C++17
0 / 100
1451 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define rep(n) for (int i = 0; i < n; ++i) #define rep2(n) for (int j = 0; j < n; ++j) #define mp make_pair #define pb push_back typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; array<int, 3> max_id (int i, int j1, int k1, int j2, int k2) { int ma = 0, cur, idj = j1, idk = k2; for (int j = j1; j <= j2; ++j) { for (int k = k1; k <+ k2; ++k) { cout << "? " << i << " " << j << " " << k << "\n" << flush; cin >> cur; if (cur>ma) { ma = cur; idj = j, idk = k; } } } return {i, idj, idk}; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, k, q; cin >> n >> m >> k >> q; int lo = 1, hi = n; while (lo<hi) { int mid = (lo+hi)/2, l = 0, a = 0, r = 0; array<int, 3> id = max_id(mid, 1, 1, m, k); if (mid>1) { cout << "? " << id[0]-1 << " " << id[1] << " " << id[2] << "\n" << flush; cin >> l; } cout << "? " << id[0] << " " << id[1] << " " << id[2] << "\n" << flush; cin >> a; if (mid<n) { cout << "? " << id[0]+1 << " " << id[1] << " " << id[2] << "\n" << flush; cin >> r; } if (a>=l&&a>=r) { cout << "! " << id[0] << " " << id[1] << " " << id[2] << "\n" << flush; break; } else if (l>r) hi = mid-1; else lo = mid+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...