2355: The Great Cleanup
内存限制:128 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:9
解决:2
题目描述
It happens to all of us. While you are happily downloading a movie or copying a file, a warning
appears on your computer screen: “disk full,” or “disk quota exceeded.”
There are several ways to deal with this. You may simply accept the fact that you will never
watch the movie you were downloading, or that you have to live the rest of your life with a single
copy of the file. You may also install a larger disk or try to acquire a larger disk quota.
A third option is to create some space on the disk by removing files that you do not re-
ally need anymore. Under Linux, you can use the command rm for this. The syntax is simple:
"rm filename" removes the file with name "filename". You may use a separate rm-command
for every single file, but you may also use a wildcard ’*’to remove multiple files in one step. For
example, "rm BAPC*" removes all files that start with "BAPC". This way, you have to type fewer
commands.
Of course, you must not remove files that you want to keep. Hence, "rm *", which is allowed,
and which removes all files in the current directory, is often not desirable.
Now, given the names of the files you want to remove, and given the names of the files you want
to keep, you have to determine the minimum number of rm-commands to get the job done. You
may only use wildcards at the end of your commands. For example, "rm *.txt" (which would
remove all ".txt" files) is not allowed.
输入
The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:
• One line with an integer N1 , satisfying 1 ≤ N1 ≤ 1000: the number of files that must be removed.
• N1 lines, each with the name of one file that must be removed.
• One line with an integer N2 , satisfying 0 ≤ N2 ≤ 1000: the number of files that must not be removed.
• N2 lines, each with the name of one file that must not be removed.
Each filename is a string x with 1 ≤ Length(x) ≤ 20, consisting of alphabetic characters (upper
case and lower case), digits and/or periods. That is, characters from the set { A, B, C, . . . , Z, a, b, c, . . . , z, 0, 1, 2, . . . , 9, . }. All N1 + N2 file names for a test case are different.
输出
For every test case in the input, the output should contain a single number, on a single line: the smallest number of rm-commands to remove exactly the right files.
样例输入 复制
1
11
BAPC.in
BAPC.out
BAPC.tex
filter
filename
filenames
clean
cleanup.IN1
cleanup.IN2
cleanup.out
problem.tex
5
BAPC
files
cleanup
cleanup.IN
cleaning
样例输出 复制
8