#P8824. [传智杯 #3 初赛] 终端
[传智杯 #3 初赛] 终端
Problem Description
One day, you got tired of the ugly and useless terminal on your computer and decided to implement your own Terminal.
More specifically, it needs to support the following commands:
-
touch filename: If the file namedfilenamedoes not exist, create such a file. If a file with the same name already exists, do nothing. -
rm name: Delete the file namedname. If such a file does not exist, do nothing. -
ls: Display all files that currently exist and have not been deleted, in the order of creation time. -
rename xxx yyy: Rename the file namedxxxtoyyy. If such a file does not exist, or if a file namedyyyalready exists, do nothing.
All file names involved consist only of uppercase or lowercase English letters, and file names are case-sensitive.
Input Format
The first line contains an integer , indicating the total number of operations to execute.
The next lines each contain a string, representing one command.
Output Format
For each ls command, output several lines, each containing one string representing a file name. If there are currently no files, output nothing.
Note that the time limit for this problem is 3 s, and the input/output size is large. Please pay attention to constant factors that affect runtime. We will not provide extra running time for contestants using Java and Python.
6
touch yyh
touch yyhtql
rename yyh yyhnb
touch qwq
rename qwq qaq
ls
yyhnb
yyhtql
qaq
Hint
For of the testdata, only operations exist.
For another of the testdata, only operations exist.
For another of the testdata, only operations exist.
For of the testdata, .
It is guaranteed that the length of every command does not exceed characters.
Translated by ChatGPT 5