# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072046 | noyancanturk | Dungeons Game (IOI21_dungeons) | C++17 | 107 ms | 78984 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;
using lint=long long;
const int lim=5e4+100,llim=25;
int n;
int jump[6][lim][llim];
lint lift[6][lim][llim];
vector<int>vals;
void init(int N,vector<int> s,vector<int> p,vector<int> w,vector<int> l) {
n=N;
set<int>st;
st.insert(0);
for(int i=0;i<n;i++){
st.insert(s[i]);
}
vals=vector<int>(st.begin(),st.end());
for(int i=0;i<vals.size();i++){
for(int j=0;j<n;j++){
if(s[j]<=vals[i]){
jump[i][j][0]=w[j];
lift[i][j][0]=s[j];
}else{
jump[i][j][0]=l[j];
lift[i][j][0]=p[j];
}
}
jump[i][n][0]=n;
lift[i][n][0]=0;
for(int k=1;k<llim;k++){
for(int j=0;j<=n;j++){
jump[i][j][k]=jump[i][jump[i][j][k-1]][k-1];
lift[i][j][k]=lift[i][j][k-1]+lift[i][jump[i][j][k-1]][k-1];
}
}
}
}
long long simulate(int x, int Z) {
lint z=Z;
int ind=0;
while(ind+1<vals.size()&&vals[ind+1]<=z)ind++;
while(1){
for(int i=llim-1;0<=i;i--){
if(ind+1==vals.size()||z+lift[ind][x][i]<vals[ind+1]){
z+=lift[ind][x][i];
x=jump[ind][x][i];
}
}
z+=lift[ind][x][0];
x=jump[ind][x][0];
if(x==n)return z;
ind++;
}
return -1;
}
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... |