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>
#define push_back pb
using namespace std ;
const int MAXN = 5005 ;
int state , cnt , par[MAXN];
string ans[MAXN] ;
void Init() {
}
void TypeLetter(char L) {
ans[cnt] = ans[state]+L;
par[cnt] = state ;
state = cnt ;
cnt ++ ;
// cerr << "current answer: " << ans[state] << endl;
}
void UndoCommands(int U) {
int u = state ;
for(int k = 0 ; k < U ; k++ ){
u = par[u] ;
}
par[cnt] = state ;
state = cnt ;
ans[state] = ans[u] ;
cnt ++ ;
// cerr << "current answer "<< ans[state]<<endl;
}
char GetLetter(int P) {
return ans[state][P];
}
// int main() {
// Init();
// int cmd_num;
// bool tmp = scanf("%d", &cmd_num);
// assert(tmp == 1);
// int i;
// for (i = 0; i < cmd_num; i++) {
// char cmd;
// tmp = scanf(" %c", &cmd);
// assert(tmp == 1);
// if (cmd == 'T') {
// char letter;
// tmp = scanf(" %c", &letter);
// assert(tmp == 1);
// TypeLetter(letter);
// }
// else if (cmd == 'U') {
// int number;
// tmp = scanf("%d", &number);
// assert(tmp == 1);
// UndoCommands(number);
// }
// else if (cmd == 'P') {
// int index;
// char letter;
// tmp = scanf("%d", &index);
// assert(tmp == 1);
// letter = GetLetter(index);
// printf("%c\n", letter);
// }
// }
// puts("Let's test for cheating!!");
// return 0;
// }
# | 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... |