제출 #1067249

#제출 시각아이디문제언어결과실행 시간메모리
1067249Itamar던전 (IOI21_dungeons)C++17
0 / 100
3 ms6748 KiB
#include <vector> using namespace std; #define vi vector<int> #define ll long long vi S,P,W,L; int N; const int siz = 5e5; #include<iostream> ll bin[siz][30]; ll tos[siz][30]; int wer[siz][30]; int wer2[siz][30]; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { S=s,P=p,W=w,L=l,N=n; for(int i = 0; i < n; i++){ bin[i][0] = s[i]; tos[i][0] = p[i]; wer[i][0] = l[i]; wer2[i][0] = w[i]; } wer[n][0]=n; wer2[n][0]=n; for(int j = 1; j < 30; j++){ for(int i = 0; i < n; i++){ wer[i][j] = wer[wer[i][j-1]][j-1]; int ind = wer[i][j-1]; tos[i][j] = tos[i][j-1] + tos[ind][j-1]; bin[i][j] = max(bin[i][j-1],bin[ind][j-1]-tos[i][j-1]); wer2[i][j] = wer2[wer2[i][j-1]][j-1]; } wer[n][j]=n; wer2[n][j]=n; } } long long simulate(int x, int z) { ll Z = z; while(x<N){ for(int j = 29; j >=0; j--){ if(wer[x][j] < N && Z+tos[x][j] <S[0]){ Z+=tos[x][j]; x = wer[x][j]; } } if(Z < S[x]){ Z += P[x]; x = L[x]; }else{ Z += S[x]; x = W[x]; } for(int j = 29; j >=0; j--){ if(wer2[x][j] < N){ Z+=S[0]*(1<<j); x = wer2[x][j]; } } if(Z < S[x]){ Z += P[x]; x = L[x]; }else{ Z += S[x]; x = W[x]; } } return Z; }
#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...