이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#include "dungeons.h"
const int LOG=25;
typedef long long ll;
struct item{
int to;
ll earn=0;
ll mn=0;
};
struct node{
vector<item>jump;
node(){
jump.resize(LOG);
}
};
vector<vector<node>>dp;
vector<int>_s,_p,_w,_l;
int _n;
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;
dp.resize(7);
for(int z=0;z<7;z++){
auto &v=dp[z];
v.resize(_n+1);
for(int i=0;i<_n;i++){
if((1<<(4*z))>=_s[i]){
v[i].jump[0].to=_w[i];
v[i].jump[0].earn=_s[i];
v[i].jump[0].mn=1e18;
}else{
v[i].jump[0].to=_l[i];
v[i].jump[0].earn=_p[i];
v[i].jump[0].mn=_s[i];
}
}
for(int i=1;i<LOG;i++){
for(int j=0;j<_n;j++){
auto a=v[j].jump[i-1],b=v[v[j].jump[i-1].to].jump[i-1];
if(a.to==_n)v[j].jump[i]=a;
else{
v[j].jump[i].to=b.to;
v[j].jump[i].earn=a.earn+b.earn;
v[j].jump[i].mn=min(a.mn,b.mn-a.earn);
}
}
}
}
return;
}
ll simulate(int x, int Z) {
long long z=Z;
for(int j=0;j<7;j++){
while(z<(1<<(4*(j+1)))){
for(int i=LOG-1;i>=0;i--){
if(z<dp[j][x].jump[i].mn){
z+=dp[j][x].jump[i].earn;
x=dp[j][x].jump[i].to;
if(x==_n)return z;
}
}
if(z>=_s[x])z+=_s[x],x=_w[x];
else z+=_p[x],x=_l[x];
if(x==_n)return z;
}
}
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... |