이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int currNode, p, i, query;
vector<int> commands;
int up[1000005][21];
typedef struct node {
int children[26];
char letter;
int dep;
node() {
fill(children, children+26, -1);
};
} node;
vector<node> trie;
void Init() {
currNode = 0;
trie.emplace_back();
trie[0].letter = 'a';
trie[0].dep = -1;
commands.push_back(0);
for (i=0; i < 21; ++i) {
up[0][i] = 0;
}
}
void TypeLetter(char L) {
p = currNode;
if (trie[currNode].children[L-'a'] == -1) {
trie[currNode].children[L-'a'] = trie.size();
trie.emplace_back();
}
currNode = trie[currNode].children[L-'a'];
trie[currNode].letter = L;
up[currNode][0] = p;
trie[currNode].dep = trie[p].dep+1;
for (i=1; i < 21; ++i) {
up[currNode][i] = up[up[currNode][i-1]][i-1];
}
commands.push_back(currNode);
}
void UndoCommands(int U) {
currNode = commands[(int)commands.size()-1-U];
commands.push_back(currNode);
}
char GetLetter(int P) {
P = trie[currNode].dep-P;
query = currNode;
for (i=0; i < 21 && P > 0; ++i) {
if (P & 1) {
query = up[query][i];
}
P >>= 1;
}
return trie[query].letter;
}
# | 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... |