이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxN = 4e5+5;
ll b[mxN][8][17], t[mxN][8][17], a[mxN][8][17];
vector<int> s, p, w, l;
int n;
const int inf = 1<<30;
void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) {
n = _n, s = _s, p = _p, w = _w, l = _l;
for(int i = 0; i < 17; ++i){
b[n][0][i] = n;
t[n][0][i] = inf;
a[n][0][i] = 0;
for(int k = 0; k < n; ++k){
if(s[k] <= (1<<i<<8)){
t[k][0][i] = inf;
a[k][0][i] = s[k];
b[k][0][i] = w[k];
}
else{
t[k][0][i] = s[k];
a[k][0][i] = p[k];
b[k][0][i] = l[k];
}
}
for(int j = 0; j < 17; ++j){
for(int k = 0; k < n; ++k){
t[k][j%8][i] = min(t[b[k][(j-1)%8][i]][(j-1)%8][i] - a[k][(j-1)%8][i], t[k][(j-1)%8][i]);
a[k][j%8][i] = a[b[k][(j-1)%8][i]][(j-1)%8][i] + a[k][(j-1)%8][i];
b[k][j%8][i] = b[b[k][(j-1)%8][i]][(j-1)%8][i];
}
}
}
}
ll simulate(int x, int _z) {
ll z = _z;
while(z <= 256 && x != n) {
if(z >= s[x]){
z += s[x];
x = w[x];
} else {
z += p[x];
x = l[x];
}
}
if(x != n){
for(int i = 0; i < 17; ++i){
assert(z >= (1<<i<<8));
for(int j = 7; ~j; --j){
while(x != n && z < t[x][j][i]){
z += a[x][j][i];
x = b[x][j][i];
}
}
while(x != n && z <= (1<<i<<9)){
if(z >= s[x]){
z += s[x];
x = w[x];
} else {
z += p[x];
x = l[x];
}
}
if(x == n)break;
}
}
return z;
}
# | 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... |