#K82762. Spam Email Classifier
Spam Email Classifier
Spam Email Classifier
You are given a list of spam words and several email messages. Your task is to determine whether an email should be classified as Spam or Not Spam based on how many spam words it contains.
Specifically, for each email, count the number of words (case-insensitive) that exactly match any of the provided spam words. An email is classified as Spam if the total count is at least \(K\), and Not Spam otherwise. Formally, if \(\text{count} \geq K\), the email is Spam; otherwise, it is Not Spam.
inputFormat
The input is read from standard input (stdin) in the following format:
- The first line contains two integers:
T
(the number of emails) andK
(the threshold for spam classification). - The second line contains an integer
N
representing the number of spam words. - The third line contains
N
spam words separated by spaces. - The next
T
lines each contain an email message.
outputFormat
For each email message, output a single line to standard output (stdout) containing either Spam
or Not Spam
according to the classification rule.
2 3
4
viagra buy cheap free
Buy now! Cheap viagra available online.
This is a free discount card for you.
Spam
Not Spam
</p>