Filesystem P38763


Statement
 

pdf   zip

thehtml

Your computer filesystem is a tree with several directories. Initially, you only have the root directory “/”. A filepath describes a path from “/” to a directory, using slashes to separate directories. For instance, “/”: only the root; “/dev/”: “dev” inside the root; “/pictures/travel/porto/”: “porto” inside “travel” inside “pictures” inside the root.

You have three commands to change the filesystem:

  • make filepath: Creates the minimum number of directories to make filepath valid.
  • erase filepath: Removes the directory described by filepath and all its content. You can assume that filepath always exists.
  • move src dst: Moves the directory src and all its content inside the directory dst. You can assume that src and dst exist, that src and dst are different, and that dst is not a subdirectory of src.

Additionally, assume that the root will never be moved nor removed. But you can make /.

Given a list of commands, print the whole filesystem with an indented tree as shown in the sample outputs. List the children of every directory in alphabetical order.

Input

Input consists of between 1 and a few thousand commands. The directory names consist of between 1 and 8 lowercase letters. Every command will create a small number of new directories, if any. At every moment, the tree will not be “too large” nor “too high”.

Output

After every command, print a line with 20 dashes followed by the filesystem tree.

Public test cases
  • Input

    make /dev/null/
    make /dev/
    make /dev/null/
    move /dev/null/ /dev/
    

    Output

    --------------------
    /
      dev
        null
    --------------------
    /
      dev
        null
    --------------------
    /
      dev
        null
    --------------------
    /
      dev
        null
    
  • Input

    make /photos/travel/
    make /test/a/b/z/
    make /test/a/z/z/
    move /photos/travel/ /test/a/b/
    make /test/d/h/
    erase /test/d/h/
    erase /test/
    move /photos/ /
    

    Output

    --------------------
    /
      photos
        travel
    --------------------
    /
      photos
        travel
      test
        a
          b
            z
    --------------------
    /
      photos
        travel
      test
        a
          b
            z
          z
            z
    --------------------
    /
      photos
      test
        a
          b
            travel
            z
          z
            z
    --------------------
    /
      photos
      test
        a
          b
            travel
            z
          z
            z
        d
          h
    --------------------
    /
      photos
      test
        a
          b
            travel
            z
          z
            z
        d
    --------------------
    /
      photos
    --------------------
    /
      photos
    
  • Information
    Author
    Albert Martínez
    Language
    English
    Official solutions
    C++
    User solutions
    C++