Submission #95557

#TimeUsernameProblemLanguageResultExecution timeMemory
95557oolimryCrayfish scrivener (IOI12_scrivener)C++14
100 / 100
636 ms72820 KiB
#include <bits/stdc++.h> int p[1000005][22]; char character[1000005]; int point[1000005]; int depth[1000005]; int x = 0; int cur = 0; int mcur = 0; void Init() { for(int i = 0;i < 22;i++) p[0][i] = -1; depth[0] = 0; } void TypeLetter(char L) { int next = mcur + 1; point[x] = next; character[next] = L; depth[next] = depth[cur] + 1; p[next][0] = cur; for(int i = 1;i < 22;i++){ if(p[next][i-1] != -1) p[next][i] = p[p[next][i-1]][i-1]; else {p[next][i] = -1; continue;} } cur = next; mcur++; x++; } void UndoCommands(int U) { cur = point[x - U - 1]; point[x] = cur; x++; } char GetLetter(int P) { int k = depth[cur] - P - 1; int node = cur; while(k > 0){ int kk = (k & (-k)); k -= kk; kk = log2(kk); node = p[node][kk]; } return character[node]; }
#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...