# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961382 | Warinchai | Dungeons Game (IOI21_dungeons) | C++17 | 158 ms | 80724 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<bits/stdc++.h>
using namespace std;
int lift[17][50005];
long long mn[17][50005];
long long dis[17][50005];
long long inf=1e18+7;
int N;
vector<int>W;
vector<int>S;
vector<int>L;
vector<int>P;
void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l) {
N=n;
S=s;
W=w;
L=l;
P=p;
for(int j=0;j<n;j++){
lift[0][j]=w[j],mn[0][j]=s[j],dis[0][j]=p[j];
}
lift[0][n]=n;
mn[0][n]=inf;
for(int j=1;j<=16;j++){
for(int k=0;k<=n;k++){
lift[j][k]=lift[j-1][lift[j-1][k]];
dis[j][k]=dis[j-1][k]+dis[j-1][lift[j-1][k]];
mn[j][k]=max(mn[j-1][k],mn[j-1][lift[j-1][k]]-dis[j-1][k]);
}
}
//cerr<<"work\n";
return;
}
long long simulate(int x, int z) {
//cerr<<"work\n";
long long c=0,lv=0;
long long pow=z;
/*while(x>(1<<c)){
lv=c;
c++;
}*/
//cerr<<x<<"\n";
//cerr<<lv<<"\n";
while(1){
//cerr<<x<<" "<<pow<<"\n";
for(int i=15;i>=0;i--){
//cerr<<i<<" "<<lv<<" "<<x<<"\n";
if(pow>=mn[i][x])pow+=dis[i][x],x=lift[i][x];
}
//cerr<<x<<" "<<pow<<"\n\n";
if(x==N)break;
pow+=P[x];
x=L[x];
}
return pow;
}
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... |