Submission #1074700

#TimeUsernameProblemLanguageResultExecution timeMemory
1074700vnm06Dungeons Game (IOI21_dungeons)C++17
37 / 100
7079 ms411984 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; int N; vector<int> S, P, W, L; int vert[7][400005][7]; long long jmp[7][400005][7]; long long gran[7][400005][7]; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { N=n; S=s; P=p; W=w; L=l; int le=1, ri=15; for(int tree=0; tree<7; tree++) { for(int i=0; i<n; i++) { if(s[i]<le) { vert[tree][i][0]=w[i]; jmp[tree][i][0]=s[i]; gran[tree][i][0]=ri; } else if(s[i]>ri) { vert[tree][i][0]=l[i]; jmp[tree][i][0]=p[i]; gran[tree][i][0]=ri; } else { vert[tree][i][0]=l[i]; jmp[tree][i][0]=p[i]; gran[tree][i][0]=s[i]-1; } } for(int lvl=1; lvl<7; lvl++) { for(int i=0; i<n; i++) { vert[tree][i][lvl]=vert[tree][i][lvl-1]; jmp[tree][i][lvl]=jmp[tree][i][lvl-1]; gran[tree][i][lvl]=gran[tree][i][lvl-1]; for(int j=1; j<=15; j++) { int nv=vert[tree][i][lvl]; if(nv==n) continue; vert[tree][i][lvl]=vert[tree][nv][lvl-1]; gran[tree][i][lvl]=min(gran[tree][i][lvl], gran[tree][nv][lvl-1]-jmp[tree][i][lvl]); jmp[tree][i][lvl]+=jmp[tree][nv][lvl-1]; } } } le*=16; ri=le*16-1; } return; } long long simulate(int x, int z) { int v=x; long long st=z; int tree=0, le=1, ri=15; while(v!=N) { ///cout<<v<<" "<<st<<endl; while(tree<6 && st>ri) { le*=16; ri=le*16-1; tree++; } for(int lvl=6; lvl>=0; lvl--) { for(int j=15; j>=0; j--) { if(st<=gran[tree][v][lvl]) { st+=jmp[tree][v][lvl]; v=vert[tree][v][lvl]; if(v==N) break; } else break; } if(v==N) break; } if(v==N) break; if(st<S[v]) { st+=P[v]; v=L[v]; } else { st+=S[v]; v=W[v]; } } return st; }
#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...