Submission #285261

#TimeUsernameProblemLanguageResultExecution timeMemory
285261TMJNCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
628 ms94456 KiB
int dp[1000000][21]; int len[1000000]; char c[1000000]; int t[1000000]; int cnt; void Init() { len[0]=-1; } void TypeLetter(char L) { cnt++; len[cnt]=len[cnt-1]+1; t[cnt]=cnt; c[cnt]=L; dp[cnt][0]=t[cnt-1]; for(int i=0;i<=19;i++){ dp[cnt][i+1]=dp[dp[cnt][i]][i]; } } void UndoCommands(int U) { cnt++; len[cnt]=len[cnt-U-1]; t[cnt]=t[cnt-U-1]; for(int i=0;i<19;i++){ dp[cnt][i+1]=dp[dp[cnt][i]][i]; } } char GetLetter(int P) { int p=t[cnt]; int l=len[p]; for(int i=20;i>=0;i--){ if(l-(1<<i)>=P){ l-=(1<<i); p=dp[p][i]; } } return c[p]; }
#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...