이 제출은 이전 버전의 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 cost=0;
ll mx=0;
};
struct node{
vector<item> a;
node(){
a.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(LOG);
for(int z=0;z<LOG;z++){
auto &v=dp[z];
v.resize(_n+1);
for(int i=0;i<_n;i++){
if((1<<z)>=_s[i]){
v[i].a[0].to=_w[i];
v[i].a[0].cost=_s[i];
v[i].a[0].mx=1e18;
}
else{
v[i].a[0].to=_l[i];
v[i].a[0].cost=_p[i];
v[i].a[0].mx=_s[i];
}
}
for(int i=1;i<LOG;i++){
for(int j=0;j<_n;j++){
auto a=v[j].a[i-1],b=v[v[j].a[i-1].to].a[i-1];
if(a.to==_n){
v[j].a[i]=a;
}
else{
v[j].a[i].to=b.to;
v[j].a[i].cost=a.cost+b.cost;
v[j].a[i].mx=min(a.mx,b.mx-a.cost);
}
}
}
}
return;
}
ll simulate(int x, int Z) {
long long z=Z;
for(int j=0;j<LOG;j++){
for(int i=LOG-1;i>=0;i--){
if(z<dp[j][x].a[i].mx){
z+=dp[j][x].a[i].cost;
x=dp[j][x].a[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... |