ENIGMA-0x03 (2025) - A3 The eVIgma Text Editor
View as PDFThe eVIgma Text Editor

In order to not only write code for problems, we decided to build a fully functional text editor, e-VI-gma! For every feature you implement you will receive extra points, which will vary depending on how efficiently the feature works.
First feature: Typewriter
Initially, we can only insert characters at the end of the text and delete the last character. However, since we do not have a full view of the text we are writing, we can request to print the -th character of the text.
Second feature: Backups
Now, besides insertions and deletions, we can create backups of our work. These backups are mutable, meaning that every insertion/deletion can be performed at the end of any copy of the text we have.
Third feature: Finally we have arrow keys!
The typewriter has been modernized and now allows us to move within the file to perform insertions and deletions anywhere! Unfortunately, the backup system stopped working, so while we are trying to fix it, it is enough to support insertions and deletions at any position in the file.
Fourth feature: We fixed the backups!
Everything works now! We can write and delete at any position of any copy of the file.
Input Format (STDIN)
First, an integer is given: the number of operations that will be performed on the file.
Then
lines follow, each describing one operation:
INSERT i s: inserts the stringsat positionin the current version (initially we are at version 1). (For example, for the first 2 features,
will always be equal to
, where
is the current length of the version.)
ERASE i k: deletescharacters starting from position
in the current version.
GET i v: prints the-th character (1-indexed) of version
SNAP: a new version which is a copy of the current one, with number \(\hbox{|current versions|} + 1\)VERSION v: sets versionas the current version.
Output Format (STDOUT)
Print a single line consisting of characters:
for every GET query, output the corresponding character.
Constraints
- For
of the test cases,
- For the remaining
,
- For
of the test cases, the maximum string length will be
- For the remaining
,
Example
Input:
5
INSERT 1 abcde
SNAP
ERASE 3 2
GET 3 1
GET 3 2
Output:
ec
Comments