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<bits/stdc++.h>
#include "dungeons.h"
using namespace std;
int ans=0,nn;
vector<int> se,le,pe,we,dis;
vector<bool> vis;
int dfs(int x)
{
if(x==nn)
return 0;
vis[x]=true;
if(dis[we[x]]==-1)
dis[x]=dfs(we[x])+se[x];
else
dis[x]=dis[we[x]]+se[x];
return dis[x];
}
void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l)
{
se.resize(n);
le.resize(n);
pe.resize(n);
we.resize(n);
dis.assign(n,-1);
vis.assign(n,false);
nn=n;
se=s;
le=l;
we=w;
pe=p;
for(int x=0;x<n;x++)
{
if(!vis[x])
dfs(x);
}
}
long long self(int x,int z)
{
if(x==nn)
return z;
if(z>=se[x])
return z+dis[x];
if(z<se[x])
return self(le[x],z+pe[x]);
return 0ll;
}
long long simulate(int x, int z)
{
return self(x,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... |