이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <vector>
#include <iostream>
using namespace std;
int cnt=0;
long long int n,s[1000005],p[1000005],l[1000005],w[1000005];
long long int step[400005][9][8];
long long int d[400005][9][8];
long long int mx[400005][9][8];
void init(int N, std::vector<int> S, std::vector<int> P, std::vector<int> W, std::vector<int> L) {
n=N;
for(int i=0;i<n;i++)s[i]=S[i];
for(int i=0;i<n;i++)p[i]=P[i];
for(int i=0;i<n;i++)w[i]=W[i];
for(int i=0;i<n;i++)l[i]=L[i];
long long int b=1;
for(int bits=0;bits<9;bits++)
{
for(int i=0;i<n;i++)
{
if(s[i]>b)
{
step[i][bits][0]=l[i];
mx[i][bits][0]=s[i];
d[i][bits][0]=p[i];
}
else
{
step[i][bits][0]=W[i];
mx[i][bits][0]=1e18;
d[i][bits][0]=S[i];
}
}
for(int len=1;len<8;len++)
{
for(int i=0;i<n;i++)
{
long long int ti=8,now=i;
mx[i][bits][len]=1e18;
while(ti--)
{
if(now==n)break;
mx[i][bits][len]=min(mx[i][bits][len],mx[now][bits][len-1]-d[i][bits][len]);
d[i][bits][len]+=d[now][bits][len-1];
step[i][bits][len]=step[now][bits][len-1];
now=step[i][bits][len];
}
}
}
b*=8;
}
return;
}
long long simulate(int x,int Z) {
//cnt++;
//if(cnt%1000==0)cout<<x<<" "<<Z<<endl;
long long int now=x;
long long int z=Z;
long long int b=1;
for(int bits=0;bits<9;bits++)
{
if(bits!=8 && b*8<=z)
{
b*=8;
continue;
}
for(int len=7;len>=0;len--)
{
long long int count=0;
while(z<mx[now][bits][len])
{
count++;
//cout<<b<<" "<<bits<<" "<<now<<" "<<z<<" "<<mx[now][bits][len]<<" "<<len<<" "<<count<<" "<<s[now]<<" "<<p[now]<<" "<<w[now]<<" "<<l[now]<<endl;
z+=d[now][bits][len];
now=step[now][bits][len];
//cout<<b<<" "<<bits<<" "<<now<<" "<<z<<" "<<mx[now][bits][len]<<" "<<len<<" "<<count<<" "<<s[now]<<" "<<p[now]<<" "<<w[now]<<" "<<l[now]<<endl;
if(now==n)break;
}
if(now==n)break;
}
if(now==n)break;
z+=s[now];
now=w[now];
if(now==n)break;
//cout<<now<<" "<<z<<endl;
b*=16;
if(z<b)
{
b/=8;
bits--;
}
}
//system("pause");
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... |