# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974405 | lucri | Crayfish scrivener (IOI12_scrivener) | C++17 | 0 ms | 0 KiB |
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 <stdlib.h>
#include <stdio.h>
#include <assert.h>
#define inbuf_len 1 << 16
#define outbuf_len 1 << 16
#include<bits/stdc++.h>
std::string ans[1000010];
int nr;
void Init()
{
return;
}
void TypeLetter(char L)
{
++nr;
ans[nr]=ans[nr-1];
ans[nr]+=L;
}
void UndoCommands(int U)
{
++nr;
ans[nr]=ans[nr-U-1];
}
char GetLetter(int P)
{
return ans[nr][P];
}
int main() {
Init();
int cmd_num;
scanf("%d", &cmd_num);
int i;
for (i = 0; i < cmd_num; i++) {
char cmd;
scanf(" %c", &cmd);
if (cmd == 'T') {
char letter;
scanf(" %c", &letter);
TypeLetter(letter);
}
else if (cmd == 'U') {
int number;
scanf("%d", &number);
UndoCommands(number);
}
else if (cmd == 'P') {
int index;
char letter;
scanf("%d", &index);
letter = GetLetter(index);
printf("%c\n", letter);
}
}
puts("Let's test for cheating!!");
return 0;
}