# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442109 | daniel920712 | Dungeons Game (IOI21_dungeons) | C++17 | 2 ms | 588 KiB |
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 <vector>
#include <stdio.h>
#include <set>
using namespace std;
long long con[15][35][50005];
long long nxt[15][35][50005];
long long how[200005];
vector < long long > fin;
set < long long > tt;
void init(int n,vector < int > s,vector < int > p,vector < int > w,vector < int > l)
{
int i,j,k;
for(i=0;i<n;i++) tt.insert((long long) s[i]);
for(auto i:s) fin.push_back(i);
how[n]=0;
for(i=n-1;i>=0;i--) how[i]=how[w[i]]+s[i];
for(k=0;k<(long long) fin.size();k++)
{
for(i=0;i<=30;i++)
{
nxt[0][i][n]=n;
con[0][i][n]=0;
}
/*for(i=0;i<n;i++)
{
if(fin[k]<=s[i])
{
nxt[k][0][i]=(long long) l[i];
con[k][0][i]=(long long) p[i];
}
else
{
nxt[k][0][i]=(long long) w[i];
con[k][0][i]=(long long) s[i];
}
}
/*for(i=1;i<=30;i++)
{
for(j=0;j<n;j++)
{
nxt[k][i][j]=nxt[k][i-1][nxt[k][i-1][j]];
con[k][i][j]=con[k][i-1][j]+con[k][i-1][nxt[k][i-1][j]];
//printf("%d %d %lld %lld\n",i,j,nxt[i][j],con[i][j]);
}
}*/
}
return;
}
long long simulate(int x, int z)
{
return 0;
long long ans=(long long) z,now=x,i,j;
for(j=0;j<fin.size();j++)
{
if(ans>=fin[j]) continue;
for(i=30;i>=0;i--)
{
if(ans+con[j][i][now]<fin[j])
{
//printf("%lld %lld %lld %lld %lld\n",ans,i,now,con[i][now],nxt[i][now]);
ans+=con[j][i][now];
now=nxt[j][i][now];
}
//printf("%lld %lld %lld\n",i,ans,now);
}
ans+=con[j][0][now];
now=nxt[j][0][now];
}
return ans+how[now];
}
Compilation message (stderr)
# | 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... |