이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 400005;
int nums, nxt[20][9][MAXN];
ll sa[MAXN], pa[MAXN], wa[MAXN], la[MAXN], gain[20][9][MAXN], md[20][9][MAXN];
void init(int n, vector<int> sv, vector<int> pv, vector<int> wv, vector<int> lv){
nums = n;
for (int i = 0; i < nums; i++){
sa[i] = sv[i]; pa[i] = pv[i]; wa[i] = wv[i]; la[i] = lv[i];
}
for (int b = 0; b <= 8; b++){
ll str = 1ll << (3 * b);
for (int i = 0; i < nums; i++){
md[0][b][i] = sa[i];
if (str >= sa[i]) nxt[0][b][i] = wa[i], gain[0][b][i] = sa[i];
else nxt[0][b][i] = la[i], gain[0][b][i] = pa[i];
}
for (int k = 1; k <= 19; k++)
for (int i = 0; i < nums; i++){
int nn = nxt[k - 1][b][i];
if (nn == nums) nxt[k][b][i] = nums;
else{
md[k][b][i] = min(md[k - 1][b][i], md[k - 1][b][nn] - gain[k - 1][b][i]);
nxt[k][b][i] = nxt[k - 1][b][nn];
gain[k][b][i] = gain[k - 1][b][i] + gain[k - 1][b][nn];
}
}
}
}
ll simulate(int x, int z) {
ll str = z, lim = 8;
for (int b = 0; x != nums;){
if (b != 8 && str >= lim){
b++; lim <<= 3; continue;
}
for (int k = 19; k >= 0; k--){
if (nxt[k][b][x] == nums || str >= md[k][b][x]) continue;
str += gain[k][b][x];
x = nxt[k][b][x];
}
if (str >= sa[x]) str += sa[x], x = wa[x];
else str += pa[x], x = la[x];
}
return str;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |