-->
当前位置:首页 > 题库

PROGRAMMING:Directory tree

Luz5年前 (2021-05-10)题库433
In the zip archive, the relative paths and names of all compressed files and directories are kept. When using GUI software such as winzip to open zip archives, the tree structure of the directory can be reconstructed from the information. Please write a program to rebuild the tree structure of the directory.
###Input format:
Input first gives a positive integer n ($$\ Le 10 ^ 4 $$), which represents the number of files and directories in the zip archive. Then n lines, each line has the relative path and name of the file or directory in the following format (no more than 260 characters per line):
-The characters in the path and name only include English letters (case sensitive);
-The symbol "\" appears only as a path separator;
-The directory ends with the symbol "\";
-There are no duplicate input items;
-The whole input size should not exceed 2MB.
###Output format:
Assume that all paths are relative to the root directory. Starting from the root directory, each directory first outputs its own name, then outputs all subdirectories in dictionary order, and then outputs all files in dictionary order. Note that in the output, you should use space to indent according to the relative relationship of the directory. Each level of directory or file is indented by 2 more spaces than the previous level.
###Input example:
```in
seven
b
c\
ab\cd
a\bc
ab\d
a\d\a
a\d\z\
```
###Output example:
```out
root
a
d
z
a
bc
ab
cd
d
c
b
```






answer:If there is no answer, please comment