问题1411--Excuses, Excuses!

1411: Excuses, Excuses!

时间限制: 1 Sec  内存限制: 128 MB
提交: 50  解决: 16
[状态] [讨论版] [提交] [命题人:]
题目描述
 法官Ito遇上一个问题:被召参加陪审团的人以相当蹩脚的借口逃避服务。为了减少听取这些愚蠢的借口所需要的时间,法官Ito要求你写一个程序,在一个被认为是站不住脚的借口列表中对一个关键字列表进行搜索。被匹配的关键字与借口无关。
输入
    程序的输入由多组数据组成。每组数据的第1行给出两个整数。第一个数字
(1 <= K <= 20)给出在搜寻中要使用的关键字的数目。第二个数字 (1 <= E <= 20) 给出要被搜寻的借口的数目。第2行到第K+1行每行给出一个关键字。第K+2行到第K+1+E行每行给出一个借口。在关键字列表中的所有关键字只包含小写字母,长度为L (1 <= L <= 20),即输入行中从第1列到第L列。所有的借口包含大写和小写字母、空格以及下述任何标点符号[".,!?#@] (不包括方括号),长度不超过70个字符。借口至少有一个非空格字符。
输出
对每个输入集合,从列表中输出最差的借口。最差借口是关键字出现最多的借口,如果一个关键字在一个借口中出现多次,每次出现被认为是一个独立的出现。一个关键字“出现”在一个借口中当且仅当它以连续的形式存在于一个字符串中,并由行开始,或行结束,或非字母字符,或空格,来给出这一关键字范围。
对每个输入集合,输出一行,在字符串“Excuse Set #”后输出集合的编号(见样例输出)。后面的行给出最差的借口,像输入一样,一个借口一行。如果有多个最差借口,按任意次序输出。在集合输出之后,再打印一空行。
样例输入 Copy
5 3
dog
ate
homework
canary
died
My dog ate my homework.
Can you believe my dog died after eating my canary... AND MY HOMEWORK?
This excuse is so good that it contain 0 keywords.
6 5
superhighway
crazy
thermonuclear
bedroom
war
building
I am having a superhighway built in my bedroom.
I am actually crazy.
1234567890.....,,,,,0987654321?????!!!!!!
There was a thermonuclear war!
I ate my dog, my canary, and my homework ... note outdated keywords?
样例输出 Copy
Excuse Set #1
Can you believe my dog died after eating my canary... AND MY HOMEWORK?

Excuse Set #2
I am having a superhighway built in my bedroom.
There was a thermonuclear war!

来源/分类