#K13641. File System Hierarchical Operations
File System Hierarchical Operations
File System Hierarchical Operations
You are given a series of file system operations that modify a hierarchical file/directory structure. There are three types of operations:
- CREATE path: Creates a file/directory at the specified
path
. The creation is only successful if the parent directory exists or if thepath
is a root-level directory (i.e. its parent is empty). If the path already exists, this operation is ignored. - DELETE path: Deletes the file/directory at the specified
path
and all its descendants. - MOVE source_path destination_path: Moves the subtree rooted at
source_path
todestination_path
. The move is only performed ifsource_path
exists and the parent directory ofdestination_path
exists. Otherwise, the operation is ignored. The new path for each moved file/directory is computed as \[ destination\_path + (original\_path - source\_path) \] in \(\LaTeX\) format.
After processing all operations, output the list of all existing file/directory paths in lexicographical order.
inputFormat
The first line of the input contains an integer \(n\) denoting the number of operations. Each of the following \(n\) lines contains one operation.
outputFormat
Output the resulting file/directory paths in lexicographical order, each on a separate line.
## sample7
CREATE /a
CREATE /a/b
CREATE /a/b/c
DELETE /a/b
CREATE /a/d
MOVE /a /e
CREATE /e/f
/e
/e/d
/e/f
</p>