标签:files ref 就是 ber 字典序 turn hat mini rdl
You are working on the user interface for a simple text-based file explorer. One of your tasks is to build a navigation pane displaying the directory hierarchy. As usual, the filesystem consists of directories which may contain files and other directories, which may, in turn, again contain files and other directories etc. Hence, the directories form a hierarchical tree structure. The top-most directory in the hierarchy is called the root directory. If directory d directly contains directory e we will say that d is the parent directory of e while e is a subdirectory od d. Each file has a size expressed in bytes. The directory size is simply the total size of all files directly or indirectly contained inside that directory.
All files and all directories except the root directory have a name — a string that always starts with a letter and consists of only lowercase letters and “.” (dot) characters. All items (files and directories) directly inside the same parent directory must have unique names. Each item (file and directory) can be uniquely described by its path — a string built according to the following rules:
The ?rst line contains an integer n (1 ≤ n ≤ 1 000) — the number of ?les. Each of the following n lines contains a string f and an integer s (1 ≤ s ≤ 1e6) — the path and the size of a single ?le. Each path is at most 100 characters long and is a valid ?le path according to the rules above. All paths will be different.
The following line contains an integer t (1 ≤ t ≤ 1e9) — the threshold directory size.
Output the minimal display of the ?lesystem hierarchy for the given threshold as described above.
9
/sys/kernel/notes 100
/cerc/problems/a/testdata/in 1000000
/cerc/problems/a/testdata/out 8
/cerc/problems/a/luka.cc 500
/cerc/problems/a/zuza.cc 5000
/cerc/problems/b/testdata/in 15
/cerc/problems/b/testdata/out 4
/cerc/problems/b/kale.cc 100
/cerc/documents/rules.pdf 4000
10000
- / 1009727
- /cerc/ 1009627
/cerc/documents/ 4000
- /cerc/problems/ 1005627
- /cerc/problems/a/ 1005508
/cerc/problems/a/testdata/ 1000008
+ /cerc/problems/b/ 119
+ /sys/ 10
8
/b/test/in.a 100
/b/test/in.b 1
/c/test/in.a 100
/c/test/in.b 1
/c/test/pic/in.a.svg 10
/c/test/pic/in.b.svg 10
/a/test/in.a 99
/a/test/in.b 1
101
- / 322
+ /a/ 100
- /b/ 101
/b/test/ 101
- /c/ 121
+ /c/test/ 121
2
/a/a/a 100
/b.txt 99
200
+ / 199
这个题目超级长,废话也超级多。大概就是做一个目录。
有n条路径,每条路径下有一个大小为val的文件。
根文件为“/”;
给一个t;
如果目录下文件大小有一个大于等于t,展开“-”;
如果都小于t,折叠“+”;
如果没有文件,则输出一个“ ”。
注意:输出路径按字典序排序。
首先把每个文件路径及其大小读入,按字典序排序。
然后把路径分开,建树。
根据题目要求输出就可以了。
有几个点注意:
内存问题,刚开始用数组存储,结果导致RE跟MLE二选一,后来改成了vector。
输出问题,这里需要采用递归输出。
剩下的就是疯狂模拟就可以了。
等下附上代码。
Gym - 101620H_Hidden Hierarchy(树+模拟)
标签:files ref 就是 ber 字典序 turn hat mini rdl
原文地址:https://www.cnblogs.com/luoxiaoyi/p/9715363.html