Submission #599384

#TimeUsernameProblemLanguageResultExecution timeMemory
599384definitelynotmeeDungeons Game (IOI21_dungeons)C++17
11 / 100
4148 ms90320 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix= vector<vector<T>>; const int T = 20000; struct jmp{ int to, plus, win; jmp merge(jmp b){ jmp ret; ret.to = b.to; ret.plus = min(int(1e7),plus+b.plus); ret.win = min(win,b.win-plus); return ret; } }; matrix<jmp> lift; vector<int> windp; int N; vector<int> S, P, W, L; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { N = n; S =s; P = p; W = w; L = l; lift = matrix<jmp>(int(log2(T+1)),vector<jmp>(n)); for(int i = 0; i < n; i++){ if(s[i] <= T){ lift[0][i] = {w[i],s[i],int(1e9)}; } else lift[0][i] = {l[i],p[i],s[i]}; if(p[i] == n) lift[0][i].win = 0; } for(int i = 1; i < lift.size(); i++){ for(int j = 0; j < n; j++) lift[i][j] = lift[i-1][j].merge(lift[i-1][lift[i-1][j].to]); } windp = vector<int>(n+1); for(int i = n-1; i >= 0; i--) windp[i] = windp[w[i]]+s[i]; return; } long long simulate(int x, int z) { int it = T; while(it-- && x != N){ if(S[x] <= z){ z+=S[x]; x=W[x]; } else { z+=P[x]; x=L[x]; } } while(x!=N && z < 1e7){ for(int i = int(lift.size())-1; i>= 0; i--){ if(lift[i][x].win > z){ z+=lift[i][x].plus; x = lift[i][x].to; } } if(S[x] <= z){ z+=S[x]; x=W[x]; } else { z+=P[x]; x=L[x]; } } return z+windp[x]; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<jmp, std::allocator<jmp> >, std::allocator<std::vector<jmp, std::allocator<jmp> > > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for(int i = 1; i < lift.size(); i++){
      |                 ~~^~~~~~~~~~~~~
#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...