Submission #63018

#TimeUsernameProblemLanguageResultExecution timeMemory
63018theknife2001Crayfish scrivener (IOI12_scrivener)C++17
60 / 100
1032 ms141888 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e6+55; int trie[N*2][26]; char letter[N]; int p[N][22]; int a[N]; int l[N]; int node; int cnt=1; int k=1; void Init() { node=cnt++; } int c,temp,nd; void TypeLetter(char L) { c=L-'a'; temp=node; if(!trie[node][c]) trie[node][c]=cnt++; node=trie[node][c]; letter[node]=L; a[k]=node; l[k]=l[k-1]+1; if(p[node][0]==0) { p[node][0]=temp; for(int i=1;i<20;i++) p[node][i]=p[p[node][i-1]][i-1]; } k++; } void UndoCommands(int U) { node=a[k-U-1]; l[k]=l[k-U-1]; a[k]=node; k++; } char GetLetter(int P) { P=l[k-1]-P-1; nd=node; for(int i=19;i>=0;i--) { if(P&(1<<i)) nd=p[nd][i]; } return letter[nd]; }
#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...