제출 #1045991

#제출 시각아이디문제언어결과실행 시간메모리
1045991Unforgettablepl던전 (IOI21_dungeons)C++17
24 / 100
7080 ms26708 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; const int INF = 1e8; vector<int> s,p,w,l; vector<vector<int>> lift; vector<vector<long long>> liftcost; vector<long long> bestans; int n; bool special_case; void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l){ ::n=n; ::s=s; ::p=p; ::w=w; ::l=l; special_case = true; for(int i=1;i<n;i++)if(s[i]!=s[0])special_case = false; if(!special_case)return; lift = vector(n+1,vector(24,0)); liftcost = vector(n+1,vector(24,0ll)); bestans = vector(n+1,0ll); for(int i=n-1;i>=0;i--){ bestans[i]=bestans[w[i]]+s[i]; lift[i][0] = l[i]; liftcost[i][0] = p[i]; } liftcost[n][0]=INF; lift[n][0]=n; for(int bit=1;bit<24;bit++){ for(int i=0;i<=n;i++){ lift[i][bit]=lift[lift[i][bit-1]][bit-1]; liftcost[i][bit]=liftcost[i][bit-1]+liftcost[lift[i][bit-1]][bit-1]; } } return; } long long simulate(int x,int z){ if(!special_case){ while(x!=n){ if(z>=s[x]){ z+=s[x]; x = w[x]; } else { z+=p[x]; x = l[x]; } } return z; } for(int bit=23;bit>=0;bit--){ if(z+liftcost[x][bit]<s[0]){ z+=liftcost[x][bit]; x=lift[x][bit]; } } if(x==n)return z; if(z<s[0]){ z+=liftcost[x][0]; x = lift[x][0]; } return z+bestans[x]; }
#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...