This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 15;
const int ALP = 30;
int trie[MAX][ALP], pai[MAX], cur, node;
char letter[MAX];
vector<int> states;
void Init() {}
void TypeLetter(char L) {
int id = L - 'a';
if(trie[cur][id] == 0){
trie[cur][id] = ++node;
pai[node] = cur;
}
cur = trie[cur][id];
letter[cur] = L;
states.emplace_back(cur);
}
void UndoCommands(int U) {
while(U-- && states.size())
states.pop_back();
cur = states.back();
}
char GetLetter(int P) {
int aux = cur;
string resp = "";
while(aux != 0){
resp += letter[aux];
aux = pai[aux];
}
return resp[P];
}
/*int main(){
int q; cin >> q;
while(q--){
int op; cin >> op;
if(op == 1){
char c; cin >> c;
TypeLetter(c);
}else if(op == 2){
int t; cin >> t;
UndoCommands(t);
}else{
int t; cin >> t;
cout << GetLetter(t) << '\n';
}
}
}*/
# | 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... |