Submission #985835

#TimeUsernameProblemLanguageResultExecution timeMemory
985835ByeWorldWorm Worries (BOI18_worm)C++14
0 / 100
775 ms344 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define fi first #define se second #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<int,int> pii; typedef pair<pii,int> ipii; vector <int> vx = {1, -1, 0, 0, 0, 0}; vector <int> vy = {0, 0, 1, -1, 0, 0}; vector <int> vz = {0, 0, 0, 0, 1, -1}; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int all, n, m, k, q; int ansx, ansy, ansz; int que(int a, int b, int c){ if(a<=0 || a>n || b<=0 || b>m || c<=0 || c>k) return -1; cout << "? " << a << ' ' << b << ' ' << c << endl; all++; int x; cin >> x; return x; } int num(int r){ int x = rng(); x = abs(x); x %= r; x++; return x; } signed main(){ cin >> n >> m >> k >> q; bool done = 0; while(all < q){ int tot = 0; int a = num(n), b = num(m), c = num(k); // cout << a << ' ' << b << ' ' << c << "abc\n"; int sta = que(a, b, c), nw = sta; while(tot < 20){ int num = -1, idx = -1, waduh = 0; // cout << nw << ' ' << a << ' '<< b << ' ' << c << " nw\n"; for(int i=0; i<2; i++){ if(all == q){ waduh = 1; break; } int ret = que(a+vx[i], b+vy[i], c+vz[i]); if(ret == -1) continue; if(nw <= ret){ idx = i; num = ret; } } if(idx==-1 && !waduh){ ansx = a; ansy = b; ansz = c; done = 1; break; } else { a += vx[idx]; b += vy[idx]; c += vz[idx]; nw = num; tot++; } } if(done) break; } cout << "! " << ansx << ' ' << ansy << ' '<< ansz << endl; }
#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...