Submission #1284625

#TimeUsernameProblemLanguageResultExecution timeMemory
1284625FaggiDungeons Game (IOI21_dungeons)C++20
0 / 100
2 ms696 KiB
#include <bits/stdc++.h> #define ll long long #define sz(x) int(x.size()) #define forn(i,n) for(i=0; i<n; i++) #define all(x) x.begin(),x.end() #define pb push_back #define mp make_pair #define fr first #define se second using namespace std; const int MAXN=4e1+1; const int LOG=20; ll up[MAXN][LOG], ma[MAXN][LOG], sum[MAXN][LOG]; vector<int>S,P,W,L; int N; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { s.pb(0); p.pb(0); w.pb(n); l.pb(n); ll i, j; N=n; S=s; P=p; W=w; L=l; for(i=0; i<=n; i++) { up[i][0]=w[i]; ma[i][0]=s[i]; sum[i][0]=s[i]; } for(i=1; i<LOG; i++) { for(j=0; j<=n; j++) { up[j][i]=up[up[j][i-1]][i-1]; ma[j][i]=max(ma[j][i-1],ma[up[j][i-1]][i-1]); sum[j][i]=sum[j][i-1]+sum[up[j][i-1]][i-1]; if(up[j][i-1]==n) { ma[j][i]=ma[j][i-1]; sum[j][i]=sum[j][i-1]; } } } return; } long long simulate(int x, int z) { ll act=z, i, ult; while(x!=N) { if(1ll*S[x]>act) { act+=P[x]; x=L[x]; } else { ult=-1; for(i=0; i<LOG; i++) { if(ma[x][i]>act) break; ult=i; } if(ult==-1) { act+=S[x]; x=W[x]; continue; } ll aux=sum[x][ult]; act+=aux; x=up[x][ult]; act+=S[x]; x=W[x]; } } return act; }
#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...