제출 #402974

#제출 시각아이디문제언어결과실행 시간메모리
402974Charis02크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
34 / 100
1041 ms14688 KiB
#include<iostream> #define MAX_N 1000004 using namespace std; struct node{ int par; int sqpar; int len; char c; }; node trie[MAX_N]; int sz; const int sqrt = 400; void init_node(int cur,int par,char c) { trie[cur].par = par; trie[cur].c = c; trie[cur].len = trie[par].len+1; if(trie[cur].len%sqrt == 0) trie[cur].sqpar = par; else trie[cur].sqpar = trie[par].sqpar; return; } int get_ancestor(int cur,int x) { while(trie[trie[cur].sqpar].len >= x) cur = trie[cur].sqpar; while(trie[cur].len > x) cur = trie[cur].par; return cur; } void Init() { init_node(0,0,'-'); trie[0].len = 0; sz = 1; return; } void TypeLetter(char L) { init_node(sz,sz-1,L); sz++; return; } void UndoCommands(int U) { trie[sz] = trie[sz-U-1]; sz++; return; } char GetLetter(int P) { // cout << "here " << P << " " << sz-1 << " " << trie[sz-1].len << " " << get_ancestor(sz-1,trie[sz-1].len-P-1) << endl; return trie[get_ancestor(sz-1,P+1)].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...