Submission #16258

#TimeUsernameProblemLanguageResultExecution timeMemory
16258CodingBugCrayfish scrivener (IOI12_scrivener)C++98
100 / 100
648 ms174676 KiB
#include <algorithm> #include <vector> #define M 1000000 using namespace std; struct Node{ char c; int h; Node *nxt; Node *par[25]; int tp; }; Node *a[M+1]; int t; void Init() { a[t=0]=new Node(); } void TypeLetter(char L) { a[t]->nxt=a[t+1]=new Node(); a[t+1]->c=L; a[t+1]->h=a[t]->h+1; Node *p=a[t]; while(p){ a[t+1]->par[a[t+1]->tp++]=p; p=p->tp>=a[t+1]->tp ? p->par[a[t+1]->tp-1] : NULL; } t++; } void UndoCommands(int U) { a[t+1]=a[t-U]; t++; } char GetLetter(int P) { Node *p=a[t]; P=p->h-P-1; for(int i=0;P;i++){ if((1<<i)&P){ P-=(1<<i); p=p->par[i]; } } return p->c; }
#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...