Submission #574336

#TimeUsernameProblemLanguageResultExecution timeMemory
574336FatihSolakCrayfish scrivener (IOI12_scrivener)C++17
34 / 100
750 ms236076 KiB
#include <bits/stdc++.h> #define N 1000005 #define K 20 using namespace std; struct node{ int par,cnt; char last; node(){ par = cnt = 0; last = '#'; } }; node sp[N][K]; int cnt = 0; void Init() {} void TypeLetter(char l) { sp[cnt+1][0].par = cnt; sp[cnt+1][0].cnt = 1; sp[cnt+1][0].last = l; cnt++; for(int j = 1;j<K;j++){ sp[cnt][j].par = sp[sp[cnt][j-1].par][j-1].par; sp[cnt][j].cnt = sp[cnt][j-1].cnt + sp[sp[cnt][j-1].par][j-1].cnt; sp[cnt][j].last = sp[sp[cnt][j-1].par][j-1].last; } } void UndoCommands(int u) { sp[cnt+1][0].par = cnt - u; sp[cnt+1][0].cnt = 0; sp[cnt+1][0].last = '#'; cnt++; for(int j = 1;j<K;j++){ sp[cnt][j].par = sp[sp[cnt][j-1].par][j-1].par; sp[cnt][j].cnt = sp[cnt][j-1].cnt + sp[sp[cnt][j-1].par][j-1].cnt; sp[cnt][j].last = sp[sp[cnt][j-1].par][j-1].last; } } char GetLetter(int p) { int tot = sp[cnt][K-1].cnt; int needed = tot - p; int tmp = cnt; for(int i = K-1;i>=0;i--){ if(sp[tmp][i].cnt < needed){ needed -= sp[tmp][i].cnt; tmp = sp[tmp][i].par; } } return sp[tmp][0].last; }
#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...