Submission #896252

#TimeUsernameProblemLanguageResultExecution timeMemory
896252Sir_Ahmed_ImranDungeons Game (IOI21_dungeons)C++17
11 / 100
157 ms107612 KiB
///~~~LOTA~~~/// #include "dungeons.h" #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define N 400001 ll n; ll l[N][41]; ll w[N][41]; ll sl[N][41]; ll sw[N][41]; ll rw[N][41]; ll rl[N][41]; void init(int m,vector<int> s,vector<int> p,vector<int> W,vector<int> L){ n=m; w[n][0]=n; rw[n][0]=1e18; for(int i=0;i<n;i++){ l[i][0]=L[i]; w[i][0]=W[i]; sl[i][0]=p[i]; sw[i][0]=s[i]; rl[i][0]=s[i]+p[i]; rw[i][0]=s[i]+s[i]; } for(int j=0;j<40;j++){ for(int i=0;i<=n;i++){ l[i][j+1]=l[l[i][j]][j]; w[i][j+1]=w[w[i][j]][j]; sl[i][j+1]=sl[i][j]+sl[l[i][j]][j]; sw[i][j+1]=sw[i][j]+sw[w[i][j]][j]; rl[i][j+1]=min(rl[l[i][j]][j],rl[i][j]+sl[l[i][j]][j]); rw[i][j+1]=max(rw[w[i][j]][j],rw[i][j]+sw[w[i][j]][j]); } } } ll simulate(int x,int z){ int t=0; ll p=x; ll q=z; while(p!=n){ if(t==1){ for(int j=40;j>=0;j--){ if(rw[p][j]<=sw[p][j]+q){ q+=sw[p][j]; p=w[p][j]; } } } else{ for(int j=40;j>=0;j--){ if(rl[p][j]>sl[p][j]+q){ q+=sl[p][j]; p=l[p][j]; } } } t=(t+1)%2; } return q; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...