#include<bits/stdc++.h>
using namespace std;
int first=0;
string ans, texts;
vector<int> parent;
void Init() {
}
void TypeLetter(char L) {
texts.push_back(L);
// if(texts.size() == 0) {
// string prev; prev.push_back(L);
// texts.push_back(L);
// } else {
// string prev=texts[texts.size()-1]; prev.push_back(L);
// texts.push_back(prev);
// }
parent.push_back(parent.size()-1);
first=0;
}
void UndoCommands(int U) {
texts.push_back(' ');
parent.push_back(parent.size()-U-1);
// string prev=texts[texts.size()-U-1];
// texts.push_back(prev);
first=0;
}
char GetLetter(int P) {
// cout << ans << endl;
// cout << texts << endl;
// for(auto x : parent) cout << x << ' ';
// cout << endl;
//return texts[texts.size()-1][P];
if(first == 0) {
int id=texts.size()-1;
while(id != -1) {
if(texts[id] != ' ') ans.push_back(texts[id]);
id=parent[id];
}
reverse(ans.begin(), ans.end());
first++;
}
return ans[P];
}
# | 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... |