Submission #105112

#TimeUsernameProblemLanguageResultExecution timeMemory
105112eriksuenderhaufCrayfish scrivener (IOI12_scrivener)C++11
100 / 100
966 ms129252 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> //#include "grader.h" using namespace std; typedef long long int ll; const int MAXN = 1e6 + 5; struct node { node *par[20]; char c; int len = 1; }; node *arr[MAXN]; int cnt = -1; node *add(char x, node *cur) { node *ret = new node; if (cur != NULL) ret->len = cur->len + 1; ret->c = x; ret->par[0] = cur; for (int i = 1; i < 20; i++) { if (ret->par[i-1] != NULL) ret->par[i] = ret->par[i - 1]->par[i - 1]; else break; } return ret; } void Init() { } void TypeLetter(char c) { cnt++; if (cnt == 0) arr[cnt] = add(c, NULL); else arr[cnt] = add(c, arr[cnt-1]); } void UndoCommands(int u) { cnt++; arr[cnt] = arr[cnt - u - 1]; } char GetLetter(int k) { node *tmp = arr[cnt]; k = tmp->len - k - 1; for (int i = 0; k != 0 && i < 20; i++) { if (k & 1) tmp = tmp->par[i]; k /= 2; } return tmp->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...