제출 #1042870

#제출 시각아이디문제언어결과실행 시간메모리
1042870Dan4Life던전 (IOI21_dungeons)C++17
0 / 100
173 ms292688 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using vi = vector<int>; using ll = long long; int n; const int mxN = (int)4e5+10; const int mxLg = 23; int S; struct jmpNode{ int loc; ll st; jmpNode(int x=-1, ll y=0){ loc=x, st=y; } }; jmpNode jmp[2][mxLg][mxN]; void init(int N, vi s, vi p, vi w, vi l) { n = N; S=s[0]; for(int i = 0; i < n; i++){ jmp[0][0][i] = jmpNode(l[i],p[i]); jmp[1][0][i] = jmpNode(w[i],s[i]); } jmp[0][0][n]=jmp[1][0][n] = jmpNode(n,0); for(int t : {0,1}){ for(int i = 1; i < mxLg; i++){ for(int j = 0; j <= n; j++){ jmp[t][i][j].loc = jmp[t][i-1][jmp[t][i-1][j].loc].loc; jmp[t][i][j].st = jmp[t][i-1][j].st+jmp[t][i-1][jmp[t][i-1][j].loc].st; } } } } ll simulate(int x, int z) { ll strength = z; for(int i = mxLg-1; i>=0; i--) if(strength+jmp[0][i][x].st < S) strength+=jmp[0][i][x].st, x=jmp[0][i][x].loc; if(strength<S) strength+=jmp[0][0][x].st, x=jmp[0][0][x].loc; for(int i = mxLg-1; i>=0; i--) if(jmp[1][i][x].loc!=n) strength+=jmp[1][i][x].st, x=jmp[1][i][x].loc; if(x!=n) strength+=jmp[1][0][x].st, x=jmp[1][0][x].loc; return strength; }
#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...