#P13630. [NWRRC 2021] Clean Up!
[NWRRC 2021] Clean Up!
题目描述
Once Charlie decided to start a new life by deleting all files in his Downloads directory. It's easy to do that using shell! It has two useful features: the command, which removes all files given as arguments, and patterns, which are replaced with the list of files matching them before executing the command.
Charlie ran , but received an response. Unfortunately, after replaced with the names of all files in the Downloads directory, it failed to run the command because it had too many arguments.
After some experiments, Charlie realized he can execute to delete all files with names starting with if there are at most such files. If more than files match this pattern, none of them will be deleted. Of course, he can replace with any string.
Help Charlie to find the smallest number of commands needed to delete all files. Assume that he can only use the command as , where consists of lowercase English letters (and can be empty).
输入格式
The first line contains two integers and --- the number of files to delete, and the maximum number of files that can be deleted by one command ().
Each of the next lines contains a single string, denoting a file name. All file names are distinct, non-empty, and consist of lowercase English letters. The total length of all file names doesn't exceed .
输出格式
Print a single integer --- the smallest number of commands needed to delete all files.
4 2
a
abc
abd
b
2
4 2
d
c
ab
a
2
5 3
please
remove
all
these
files
3
提示
In the first example test, Charlie can execute to delete files and , and then execute to delete files and . Note that he can't just run immediately, because initially all four files match an empty prefix.