제출 #861492

#제출 시각아이디문제언어결과실행 시간메모리
861492Trisanu_DasWorm Worries (BOI18_worm)C++17
컴파일 에러
0 ms0 KiB
//Randomization OP!! #include <bits/stdc++.h> using namespace std; int n, m, k, q; int dx[] = {1, 0, 0, -1, 0, 0}; int dy[] = {0, 1, 0, 0, -1, 0}; int dz[] = {0, 0, 1, 0, 0, -1}; map<tuple<int,int,int>,int> save; mt19937 rng(time(0)); int ask(int a,int b,int c){ if(save.find({a,b,c}) != memo.end()) return save[{a,b,c}]; cout << "? " << a << ' ' << b << ' ' << c << endl; int x; cin >> x; return memo[{a,b,c}] = x; } void submit(int a,int b,int c){ cout << "! " << a << ' ' << b << ' ' << c << endl; exit(0); } int bad(int a, int b, int c){ return a <= 0 || b <= 0 || c <= 0 || a > n || b > m || c > k; } int main(){ cin >> n >> m >> k >> q; int Q = q; tuple<int,int,int,int> ans = {0,0,0,0}; for(int i = 0; i < (Q >> 1); i++){ int x = rng() % n + 1, y = rng() % m + 1, z = rng() % k + 1; ans = max(ans, {ask(x , y , z), x, y, z}); } auto[cur,x,y,z] = ans; while(q){ bool done=true; for(int i = 0; i < 6; i++){ int nx = x + dx[i], ny = y + dy[i], nz = z+dz[i]; if(bad(nx, ny, nz)) continue; int res = ask(nx, ny, nz); if(res > cur){ cur = res; x = nx; y = ny; z=nz; done = false; break; } } if(done) break; } submit(x, y, z); }

컴파일 시 표준 에러 (stderr) 메시지

worm.cpp: In function 'int ask(int, int, int)':
worm.cpp:13:27: error: 'memo' was not declared in this scope
   13 |  if(save.find({a,b,c}) != memo.end()) return save[{a,b,c}];
      |                           ^~~~
worm.cpp:16:9: error: 'memo' was not declared in this scope
   16 |  return memo[{a,b,c}] = x;
      |         ^~~~