제출 #680002

#제출 시각아이디문제언어결과실행 시간메모리
680002Ahmed57Crayfish scrivener (IOI12_scrivener)C++14
0 / 100
504 ms82416 KiB
#include <bits/stdc++.h> using namespace std; char arr[1000001]; int len[1000001]; map<int,int> mp; int op = 0 , root = 0 , node = 0; int lift[1000001][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"; }*/
#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...