spoj#DELCOMM2. DEL Command II
DEL Command II
It is required to find out what's the maximum number of files that can be deleted from MS-DOS directory executing the DEL command of MS-DOS operation system only once. There are no nested subdirectories.
A note
DEL command has the following format: DEL wildcard
The actual wildcard as well as a full file name can be made up of
a name containing 1 up to 8 case-sensitive characters.
In a wildcard the characters
'?' and '*' can be used. A question mark substitutes exactly one character
of the full file name, an asterisk any sequence of characters even empty one.
MS-DOS system can permit maybe other wildcards but they can not be used
in this task. File names
consist only of Latin letters and digits.
Input
The first line of the input is an integer M, then a blank line followed by M datasets. There is a blank line between datasets.
Input data for each dataset contains a list of full file names without any extra empty lines and spaces. Each name is written in a separate line of input data file and ended with a control sign: '+' for delete or '-' for keep. Full file names are not repeated. The list comprises at least one file, and at least one file is marked to be deleted. There are no more than 250 files.
Output
For each dataset, write to the first line of output the maximum number of files one DEL command can delete.
Example
Input: 2 BP + BPC + TURBO - EXCHANGE + EXT + HARDWARE + MOUSE – NETWORK – Output: 2 2
Hint:
For the two tests above,the corresponding DEL commands are DEL BP* and DEL EX*.
Link
You can try problem DELCOMM first. It's far easier than this problem.