| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 340 | 222 | 188 | 64.384% |
In the runup to a hurricane, it is extremely important to warn as many people as possible on or near the hurricane’s path. That way, they can ideally travel somewhere safer, reinforce their homes, and — if they have to stay — stock up on essentials, install backup power systems, etc. The question is then how you reach as many people as possible. If you make announcements on TV, then people who don’t watch TV may miss the warnings and instructions. Here, you will be given a description of which media different people consume, and which media the authorities are using for their warnings, and are to determine how many people received the warning.
Specifically, this information will be encoded as strings of letters. Each letter corresponds to one type of media, such as ‘T’ for TV, ‘F’ for Fakebook, or ‘X’ for ex-Twitter. If there is a common letter between the string for the media used and the media consumed, then the person will be informed; otherwise not.
The first line contains a number 1 ≤ K ≤ 100, which is the number of input data sets in the file. This is followed by K data sets of the following form:
The first line of a data set contains an integer 0 ≤ n ≤ 10000, the number of people we are considering.
The next line is a string of 1–10 upper-case letters (no other symbols will occur), describing the media used to announce the hurricane. This is followed by n lines, each of 1–10 upper-case letters (again, no other symbols); line i gives the media consumed by person i.
For each data set, first output “Data Set x:” on a line by itself, where x is its number. Then output the number of people who received the hurricane warning (through at least one type of media).
Each data set should be followed by a blank line.
2 4 FFXT XXXXXXX ABCDE Y FT 3 A BCDEFGHIJ KLMNOPQRST UVWXYZBCD
Data Set 1: 2 Data Set 2: 0