Submission #505672

#TimeUsernameProblemLanguageResultExecution timeMemory
505672wiwihoWorm 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; mt19937 rnd(48763); 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; r = x; if(r == -1) exit(0); _qry[mt(x, y, z)] = r; cnt++; } return _qry[mt(x, y, z)]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int q; cin >> n >> m >> k >> q; assert(m == 1 && k == 1); //for(int i = 1; i <= n; i++) cerr << query(i, 1, 1) << " "; //cerr << "\n"; int l = 1, r = n; while(l < r){ int mid = (l + r) / 2; //cerr << l << " " << r << " " << mid << "\n"; if(query(mid, 1, 1) < query(r, 1, 1)) l = mid + 1; else if(query(mid, 1, 1) < query(l, 1, 1)) r = mid; else if(query(mid, 1, 1) < query(mid + 1, 1, 1)) l = mid + 1; else r = mid; } //cerr << l << " " << query(l - 1, 1, 1) << " " << query(l, 1, 1) << " " << query(l + 1, 1, 1) << "\n"; //assert(query(l - 1, 1, 1) <= query(l, 1, 1)); //assert(query(l + 1, 1, 1) <= query(l, 1, 1)); //cerr << cnt << "\n"; cout << "! " << l << " " << 1 << " " << 1 << "\n"; 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...