Submission #680011

#TimeUsernameProblemLanguageResultExecution timeMemory
680011Ahmed57Crayfish scrivener (IOI12_scrivener)C++14
0 / 100
47 ms18184 KiB
#include <bits/stdc++.h> using namespace std; char arr[100001]; int len[100001]; int mp[100001]; int op = 0 , root = 0 , node = 0; int lift[100001][20]; void Init(){ mp[op] = root; } void TypeLetter(char l){ node++; lift[node][0] = root; for(int i = 1;i<20;i++){ lift[node][i] = lift[lift[node][i-1]][i-1]; } len[node] = len[root]+1; root = node; op++; mp[op] = root; arr[root] = l; } void UndoCommands(int u){ mp[op+1] = mp[op-u]; root = mp[++op]; } char GetLetter(int p){ int cc = root; p = (p+1)-len[root]; for(int i = 19;i>=0;i--){ if(p>=(1<<i)){ p-=(1<<i); cc =lift[cc][i]; } } return arr[cc]; } /* int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); Init(); TypeLetter('a'); cout<<root<<"\n"; TypeLetter('b'); cout<<root<<"\n"; cout<<GetLetter(1)<<"\n"; TypeLetter('d'); cout<<root<<"\n"; UndoCommands(2); cout<<root<<"\n"; UndoCommands(1); cout<<root<<"\n"; cout<<GetLetter(2)<<"\n"; TypeLetter('e'); UndoCommands(1); UndoCommands(5); TypeLetter('c'); cout<<GetLetter(2)<<"\n"; UndoCommands(2); cout<<GetLetter(2)<<"\n"; } */
#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...