이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_LOG = 20;
const int MAX_SIZE = 26;
struct Node{
char val;
int depth;
map<char, Node*> figli;
Node* father[MAX_LOG];
Node(char val, int depth) : val(val), depth(depth){
for(int i=0; i<MAX_LOG; i++)
father[i] = nullptr;
}
Node(char val, int depth, Node* N) : val(val), depth(depth){
father[0] = N;
for(int i=1; i<MAX_LOG; i++)
if(father[i-1] != nullptr)
father[i] = father[i-1]->father[i-1];
else
father[i] = nullptr;
}
};
Node* root;
vector<Node*> version;
void Init() {
root = new Node('\0', -1);
version.push_back(root);
}
void TypeLetter(char L) {
//aggiungi la lettera come nuova versione
if(version.back()->figli.count(L-'a') == 0){
version.back()->figli[L-'a'] = new Node(L, version.back()->depth+1, version.back());
}
version.push_back(version.back()->figli[L-'a']);
}
void UndoCommands(int U) {
version.push_back(version[version.size()-U-1]);
}
char GetLetter(int P) {
Node* node = version.back();
int L = version.back()->depth - P;
for(int i=0; (1<<i)<=L; i++)if(L&(1<<i))
node = node->father[i];
return node->val;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |