Submission #505314

#TimeUsernameProblemLanguageResultExecution timeMemory
505314wiwihoWorm Worries (BOI18_worm)C++14
0 / 100
1 ms456 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 l = 1, r = n; while(l < r){ int mid = (l + r) / 2; if(query(mid - 1, y, z) > query(mid, y, z)) r = mid - 1; else if(query(mid + 1, y, z) > query(mid, y, z)) l = mid + 1; else l = r = mid; } return l; } 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); cin >> n >> m >> k; assert(m == 1 && k == 1); int x = findmx1(1, 1); cout << "! " << x << " " << 1 << " " << 1 << "\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...