#K35012. File System Directory Manager

    ID: 25437 Type: Default 1000ms 256MiB

File System Directory Manager

File System Directory Manager

You are required to implement a simple file system that supports two operations:

  • mkdir path: Create a directory at the specified path. If intermediate directories do not exist, create them. If a directory already exists, do nothing.
  • ls path: List the names of the directories immediately under the specified path in lexicographical (alphabetical) order. If there are no directories, output an empty line.

The file system initially contains only the root directory (denoted by /).

Input/Output

The program will read a series of commands from the standard input and execute them sequentially. For every ls command, the program should print the resulting list of directory names (separated by a single space) to standard output on its own line.

Note: The path is always given in Unix-style format (e.g. /a/b) and you can assume that all input commands are valid.

inputFormat

The first line of input contains an integer N representing the number of commands. The following N lines each contain a command in one of the following two formats:

  • mkdir /path/to/directory
  • ls /path/to/directory

outputFormat

For each ls command in the input, output a single line containing the names of directories immediately inside the specified path, separated by a single space and sorted in lexicographical order. If there are no directories, output an empty line.

## sample
6
mkdir /a
mkdir /a/b
mkdir /c
ls /
mkdir /a/d
ls /a
a c

b d

</p>