Submission #505479

#TimeUsernameProblemLanguageResultExecution timeMemory
505479wiwihoWorm Worries (BOI18_worm)C++14
14 / 100
947 ms9792 KiB
#include <bits/stdc++.h> #define eb emplace_back #define mt make_tuple #define mp make_pair #define F first #define S second #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; using pii = pair<int, int>; using tiii = tuple<int, int, int>; const int MAX = 1e9; int n, m, k; map<tiii, int> _qry; int cnt = 0; int query(int x, int y, int z){ if(x <= 0 || x > n || y <= 0 || y > m || z <= 0 || z > k) return 0; if(_qry.find(mt(x, y, z)) == _qry.end()){ cout << "? " << x << " " << y << " " << z << "\n" << flush; int r = 0; cin >> r; if(r == -1) exit(0); _qry[mt(x, y, z)] = r; cnt++; } return _qry[mt(x, y, z)]; } int findmx1(int y, int z){ int x = -1, mx = -1; for(int i = 1; i <= n; i++){ int tmp = query(i, y, z); if(tmp > mx) mx = tmp, x = i; } return x; } pii findmx2(int z){ int x = -1, y = -1, mx = -1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ int tmp = query(i, j, z); if(tmp > mx) mx = tmp, x = i, y = j; } } return mp(x, y); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int q; cin >> n >> m >> k >> q; int x = -1, y = -1, z = -1; { int l = 1, r = k; while(l < r){ int mid = (l + r) / 2; int x, y; tie(x, y) = findmx2(mid); if(query(x, y, mid + 1) >= query(x, y, mid)) l = mid + 1; else if(query(x, y, mid - 1) >= query(x, y, mid)) r = mid - 1; else l = r = mid; } z = l; } tie(x, y) = findmx2(z); cout << "! " << x << " " << y << " " << z << "\n" << flush; 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...