UVa 409 excuses, excuses! (String match)

Source: Internet
Author: User
Tags alphabetic character keyword list time limit

409-excuses, excuses!

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem &problem=350

Judge Ito is has a problem with people subpoenaed for jury duty giving rather lame the in order to excuses avoid. In order to reduce the amount of time required listening to goofy excuses, Judge Ito has asked this write a program th At would search for a list of keywords in a list of excuses identifying lame excuses. Keywords can be matched in a excuse regardless of case.

Input

Input to your program would consist of multiple sets of data.

Line 1 of each set would contain exactly two integers. The ( ) defines the number of keywords to is used in the search. The second number ( ) defines the number of excuses in the set to be searched.

Lines 2 through k+1 each contain exactly one keyword.

Lines k+2 through k+1+e each contain exactly one excuse.

All keywords in the keyword list would contain only contiguous lower case alphabetic of length L ( ) A nd would occupy columns 1 through L in the input line.

All excuses can contain any upper or lower case alphanumeric character, a spaces, or any of the following punctuation [Spmamp ".,!? Not including the square brackets and won't exceed characters in length.

Excuses'll contain at least 1 non-space character.

Output

For each input set, your are to print the worst excuse (s) from the list.

The worst excuse (s) is/are defined as the excuse (s) which contains the largest number of incidences of keywords.

If A keyword occurs more than once in a excuse, each occurrance is considered a separate incidence.

A keyword ' occurs ' in A excuse if and only if it exists in the string, contiguous form and is delimited by the Beginni Ng or end of the line or no non-alphabetic character or a space.

For each set of input, you are are to print a single and the number of the set immediately after the string ' excuse set #". (The Sample Output). The following line (s) is is/are to contain the worst excuse (s) one per line exactly as read in. If there is more than one worst excuse, your may print them in any order.

After each set of output, your should print a blank line.

Sample Input

5 3
Dog
ate
homework
Canary
died my
dog ate my homework.
Can You believe I dog died after eating my canary ... And my homework?
This excuse was so good the 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?

Sample Output

Excuse Set #1Can your believe my dog died after eating my canary ... And my homework? Excuse Set #2I am has a superhighway built in my bedroom. There was a thermonuclear war!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.