Submission #741819

#TimeUsernameProblemLanguageResultExecution timeMemory
741819arthur_nascimentoDungeons Game (IOI21_dungeons)C++17
11 / 100
3644 ms2033236 KiB
#include "dungeons.h" #include <vector> #include <bits/stdc++.h> #define pb push_back using namespace std; #define lg 50 #define maxn 50400 #define inf 2002000 #define debug int jmp[lg][lg][maxn]; int inc[lg][lg][maxn]; int least[lg][lg][maxn]; vector<int> strength, inc_lose, go_win, go_lose; int n; void init(int N, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { n = N; strength = s; inc_lose = p; go_win = w; go_lose = l; strength.pb(0); inc_lose.pb(0); go_win.pb(n); go_lose.pb(n); debug("ini!\n"); for(int k=0;k<lg;k++){ for(int i=0;i<n;i++){ if(strength[i] <= (1<<k)) jmp[k][0][i] = go_win[i], inc[k][0][i] = strength[i], least[k][0][i] = inf; else jmp[k][0][i] = go_lose[i], inc[k][0][i] = inc_lose[i], least[k][0][i] = strength[i]; if(k == 0) debug("%d -> %d\n",i,jmp[k][0][i]); if(jmp[k][0][i] == n) least[k][0][i] = -1; } for(int j=1;j<lg;j++) for(int i=0;i<n;i++) jmp[k][j][i] = jmp[k][j-1][jmp[k][j-1][i]], inc[k][j][i] = inc[k][j-1][i] + inc[k][j-1][ jmp[k][j-1][i] ], least[k][j][i] = min( least[k][j-1][i], least[k][j-1][ jmp[k][j-1][i] ] - inc[k][j-1][i] ); } return; } long long simulate(int x, int z) { int rep = 0; while(x < n){ rep++; if(rep > 100) return 0; int aux = z, k = 0; while(aux > 1) aux /= 2, k++; debug("x %d z %d k %d\n",x,z,k); for(int i=0;i<n;i++) debug("k %d i %d -> %d\n",k,i,jmp[k][0][i]); debug("\n"); for(int j=lg-1;j>=0;j--) if(least[k][j][x] > z){ z += inc[k][j][x]; debug("%d jmp %d to %d add %d\n",x,1<<j,jmp[k][j][x],inc[k][j][x]); x = jmp[k][j][x]; } debug("z %d x %d stx %d\n",z,x,strength[x]); assert(z >= strength[x]); z += strength[x]; x = go_win[x]; } debug("ans %d\n",z); return z; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:33:8: warning: statement has no effect [-Wunused-value]
   33 |  debug("ini!\n");
      |       ~^~~~~~~~~
dungeons.cpp:49:11: warning: left operand of comma operator has no effect [-Wunused-value]
   49 |     debug("%d -> %d\n",i,jmp[k][0][i]);
      |           ^~~~~~~~~~~~
dungeons.cpp:49:37: warning: right operand of comma operator has no effect [-Wunused-value]
   49 |     debug("%d -> %d\n",i,jmp[k][0][i]);
      |                                     ^
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:81:9: warning: left operand of comma operator has no effect [-Wunused-value]
   81 |   debug("x %d z %d k %d\n",x,z,k);
      |         ^~~~~~~~~~~~~~~~~~
dungeons.cpp:81:30: warning: right operand of comma operator has no effect [-Wunused-value]
   81 |   debug("x %d z %d k %d\n",x,z,k);
      |                              ^
dungeons.cpp:81:32: warning: right operand of comma operator has no effect [-Wunused-value]
   81 |   debug("x %d z %d k %d\n",x,z,k);
      |                                ^
dungeons.cpp:84:10: warning: left operand of comma operator has no effect [-Wunused-value]
   84 |    debug("k %d i %d -> %d\n",k,i,jmp[k][0][i]);
      |          ^~~~~~~~~~~~~~~~~~~
dungeons.cpp:84:32: warning: right operand of comma operator has no effect [-Wunused-value]
   84 |    debug("k %d i %d -> %d\n",k,i,jmp[k][0][i]);
      |                                ^
dungeons.cpp:84:45: warning: right operand of comma operator has no effect [-Wunused-value]
   84 |    debug("k %d i %d -> %d\n",k,i,jmp[k][0][i]);
      |                                             ^
dungeons.cpp:86:9: warning: statement has no effect [-Wunused-value]
   86 |   debug("\n");
      |        ~^~~~~
dungeons.cpp:92:11: warning: left operand of comma operator has no effect [-Wunused-value]
   92 |     debug("%d jmp %d to %d add %d\n",x,1<<j,jmp[k][j][x],inc[k][j][x]);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~
dungeons.cpp:92:43: warning: right operand of comma operator has no effect [-Wunused-value]
   92 |     debug("%d jmp %d to %d add %d\n",x,1<<j,jmp[k][j][x],inc[k][j][x]);
      |                                           ^
dungeons.cpp:92:41: warning: right operand of comma operator has no effect [-Wunused-value]
   92 |     debug("%d jmp %d to %d add %d\n",x,1<<j,jmp[k][j][x],inc[k][j][x]);
      |                                        ~^~~
dungeons.cpp:92:56: warning: right operand of comma operator has no effect [-Wunused-value]
   92 |     debug("%d jmp %d to %d add %d\n",x,1<<j,jmp[k][j][x],inc[k][j][x]);
      |                                             ~~~~~~~~~~~^
dungeons.cpp:97:9: warning: left operand of comma operator has no effect [-Wunused-value]
   97 |   debug("z %d x %d stx %d\n",z,x,strength[x]);
      |         ^~~~~~~~~~~~~~~~~~~~
dungeons.cpp:97:32: warning: right operand of comma operator has no effect [-Wunused-value]
   97 |   debug("z %d x %d stx %d\n",z,x,strength[x]);
      |                                ^
dungeons.cpp:97:44: warning: right operand of comma operator has no effect [-Wunused-value]
   97 |   debug("z %d x %d stx %d\n",z,x,strength[x]);
      |                                            ^
dungeons.cpp:104:8: warning: left operand of comma operator has no effect [-Wunused-value]
  104 |  debug("ans %d\n",z);
      |        ^~~~~~~~~~
#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...