제출 #1128196

#제출 시각아이디문제언어결과실행 시간메모리
1128196LudisseyWorm Worries (BOI18_worm)C++20
22 / 100
33 ms756 KiB
#include <bits/stdc++.h> #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() using namespace std; vector<int> a; map<pair<int,pair<int,int>>,int> req; int n,m,k,q; void give_ans(int x, int y, int z){ cout << "! " << x+1 << " " << y+1 << " " << z+1 << endl; return; } int ask(int x, int y, int z){ if(req.find({x,{y,z}})!=req.end()) return req[{x,{y,z}}]; if(x<0||x>=n||y<0||y>=m||z<0||z>=k) return -1e9; cout << "? " << x+1 << " " << y+1 << " " << z+1 << endl; int ans; cin>>ans; req[{x,{y,z}}]=ans; return ans; } const int RAND=350; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k >> q; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<pair<int,pair<int,int>>> randomPOINT(RAND); for (int i = 0; i < RAND; i++) { randomPOINT[i].second={uniform_int_distribution<int>(0, n-1)(rng),uniform_int_distribution<int>(0, m-1)(rng)}; randomPOINT[i].first=ask(randomPOINT[i].second.first, randomPOINT[i].second.second,0); } sort(rall(randomPOINT)); int x=randomPOINT[0].second.first; int y=randomPOINT[0].second.second; while(true){ int u=ask(x,y+1,0); int d=ask(x,y-1,0); int l=ask(x-1,y,0); int r=ask(x+1,y,0); int c=ask(x,y,0); int mx=max(max(u,d),max(l,r)); if(c>=mx) break; else if(u==mx) y++; else if(d==mx) y--; else if(l==mx) x--; else if(r==mx) x++; } give_ans(x,y,0); 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...