#P8824. Simulated Terminal
Simulated Terminal
Simulated Terminal
This problem requires you to simulate a simple terminal that supports file operations. The terminal must support the following commands:
touch filename: Create a file namedfilenameif it does not already exist.rm name: Remove the file namednameif it exists.ls: List all existing (i.e. not deleted) files in the order of their creation.rename oldName newName: Rename the fileoldNametonewNameifoldNameexists and there is no file with the namenewName.
All filenames consist solely of uppercase or lowercase English letters and are case-sensitive.
For each ls command, output the names of all current files separated by a single space. If no file exists, output an empty line.
Note that the order of the files is determined by the creation time. Renaming a file does not change its original creation order.
All formulas, if any, should be in LaTeX format; however, this problem does not require any formulas.
inputFormat
The first line contains an integer N representing the number of commands. The next N lines each contain one command. Each command is one of the following:
touch filenamerm namelsrename oldName newName
Filenames are non-empty strings consisting only of uppercase and lowercase English letters.
outputFormat
For every ls command encountered in the input, output one line showing all current filenames (i.e. not deleted) separated by a single space in the order of their creation. If there are no files, output an empty line.
sample
8
touch a
touch b
ls
rename a c
ls
rm b
ls
lsa b
c b
c
c
</p>