Submission #1129810

#TimeUsernameProblemLanguageResultExecution timeMemory
1129810KerimWorm Worries (BOI18_worm)C++20
0 / 100
0 ms408 KiB
#include "bits/stdc++.h" using namespace std; int n, m, k, ask; int dx[]={+1,-1,0,0,0,0}; int dy[]={0,0,+1,-1,0,0}; int dz[]={0,0,0,0,+1,-1}; map<vector<int>, int> value, vis; int get(int x, int y, int z){ if (x < 1 or y < 1 or z < 1 or x > n or y > m or z > k) return 0; if (value.find({x, y, z}) != value.end()) return value[{x, y, z}]; // ask += 1; // return value[{x, y, z}] = rand()%5; cout<<"? "<<x<<" "<<y<<" "<<z<<endl; int resp; scanf("%d", &resp); return resp; } int main(){ srand(time(0)); // n = 100; // m = 100; // k = 100; // cout<<"board size "<<n*m*k<<endl; scanf("%d%d%d", &n, &m, &k); int K = 7; //sample size, siuuuu int sx, sy, sz, record = 0; while (K--){ int x = rand()%n+1; int y = rand()%m+1; int z = rand()%k+1; if (get(x, y, z) > record){ record = get(x, y, z); sx = x; sy = y; sz = z; } } while (1){ int stop = 1; for (int i = 0; i < 6; i++) stop &= vis[{sx, sy, sz, i}]; if (stop) break; int dir = rand()%6; while (vis[{sx, sy, sz, dir}]) dir = rand()%6; vis[{sx, sy, sz, dir}] = 1; sx += dx[dir]; sy += dy[dir]; sz += dz[dir]; if (get(sx, sy, sz) > record) record = get(sx, sy, sz); else{ sx -= dx[dir]; sy -= dy[dir]; sz -= dz[dir]; } } cout<<"! "<<sx<<" "<<sy<<" "<<sz<<endl; // cout<<"asked "<<ask<<endl; }

Compilation message (stderr)

worm.cpp: In function 'int get(int, int, int)':
worm.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d", &resp);
      |         ~~~~~^~~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d%d%d", &n, &m, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...