This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
const int N=4e5+100;
const int L=26;
int st[N][L][6];
long long we[N][L][6];
set<int> stt;
vector<long long> vec;
int sz;
int nnn;
void init(int nn,vector<int> s,vector<int> p,vector<int> w,vector<int> l){
nnn=nn;
for(auto x:s){
stt.insert(x);
}
vec.push_back(0);
for(auto x:stt)vec.push_back(x);
vec.push_back(1e18);
sz=vec.size();
for(int k=0;k<sz-1;k++){
for(int i=0;i<nnn;i++){
if(vec[k]>=s[i]){
st[i][0][k]=w[i];
we[i][0][k]=s[i];
}
else{
st[i][0][k]=l[i];
we[i][0][k]=p[i];
}
}
st[nnn][0][k]=nnn;
for(int j=1;j<L;j++){
for(int i=0;i<=nnn;i++){
st[i][j][k]=st[st[i][j-1][k]][j-1][k];
we[i][j][k]=we[i][j-1][k]+we[st[i][j-1][k]][j-1][k];
}
}
}
}
long long simulate(int xx, int zz){
int x=xx;
long long z=zz;
for(int k=0;k<sz-1;k++){
if((long long)vec[k+1]<=z)continue;
for(int j=L-1;j>=0;j--){
int nx=st[x][j][k];
long long nz=z+we[x][j][k];
if(nx!=nnn&&nz<vec[k+1]){
x=nx;
z=nz;
}
}
if(x!=nnn&&z<vec[k+1]){
z=z+we[x][0][k];
x=st[x][0][k];
}
}
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... |