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;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
const ll M=4e5+10;
const ll inf=2e18;
const ll lg=30;
ll go[lg][M],sm[lg][M],awin[M],difficulty;
void init(int n,vector<int>s,vector<int>p,vector<int>w,vector<int>l) {
l.pb(n);
p.pb(0);
awin[n]=0;
for(int i=n-1;i>=0;i--){
awin[i]=awin[w[i]]+s[0];
}
difficulty=s[0];
for(int i=0;i<=n;i++)
go[0][i]=l[i],sm[0][i]=p[i];
for(int bit=1;bit<lg;bit++){
for(int i=0;i<=n;i++){
sm[bit][i]=sm[bit-1][i]+sm[bit-1][go[bit-1][i]];
go[bit][i]=go[bit-1][go[bit-1][i]];
}
}
}
long long simulate(int x, int z){
for(int bit=lg-1;bit>=0;bit--){
if(z+sm[bit][x]<difficulty)
z+=sm[bit][x],x=go[bit][x];
}
if(z<difficulty)
z+=sm[0][x],x=go[0][x];
z+=awin[x];
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... |