#C5900. Taco File System Simulator
Taco File System Simulator
Taco File System Simulator
You are given a file system that supports a sequence of operations:
- CREATE directory_name: Create a new directory with the given name. If the directory already exists as a top-level directory, do nothing.
- ADD filename directory_name: Add a file with the given name to the specified directory (if it exists as a top-level directory). If the directory does not exist, ignore the command.
- MOVE src_directory dest_directory: Move the source directory (including all its files and subdirectories) to be a subdirectory of the destination directory. Also, merge the files from the source into the destination directory. After the move, the source directory is no longer a top-level directory.
- COUNT directory_name: Print the total number of distinct files in the given directory and in all its subdirectories recursively.
Note: Use LaTeX formatting if needed, for example: $\{a, b, c\}$ represents a set. The operations are processed sequentially and the output for each COUNT command is produced immediately.
inputFormat
The first line of input contains an integer , representing the number of commands. The next lines each contain a command in one of the following formats:
- CREATE directory_name
- ADD filename directory_name
- MOVE src_directory dest_directory
- COUNT directory_name
Commands are read from stdin and must be processed in the given order.
outputFormat
For each COUNT command, print on a new line the total number of distinct files found in the specified directory (including all files in its subdirectories recursively). The outputs should be printed to stdout.## sample
6
CREATE root
ADD file1 root
CREATE sub
MOVE root sub
COUNT sub
ADD file2 sub
1