ZOJ Problem Set - 1635
Given a tree of UNIX directories and file/directory sizes, you are supposed to list them as a tree with proper indention and sizes.
The input consists of several test cases. Each case consists of several lines which represent the levels of the directory tree. The first line contains the root file/directory. If it is a directory, then its children will be listed in the second line, inside a pair of parentheses. Similarly, if any of its children is a directory, then the contents of that directory will be listed in the next line, inside a pair of parentheses. The format of a file/directory is:
For each test case, list the tree in the format shown by the sample. Files/directories that are of depth d will have their names indented by 8d spaces. Do NOT print tabs to indent the output. The size of a directory D is the sum of the sizes of all the files/directories in D, plus its own size.
*/usr 1 (*mark 1 *alex 1) (hw.c 3 *course 1) (hw.c 5) (aa.txt 12) */usr 1 ()
|_*/usr |_*mark | |_hw.c | |_*course | |_aa.txt |_*alex |_hw.c |_*/usr
Author: CHEN, Yue
Source: Zhejiang University Local Contest 2003