Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 512M

Problem types

Gozz is now president of UCC and has set himself the task of returning the club to glory. In this quest he must review UCC scripture in search of a great Oracle. Unfortunately you have been confused for a member (that cares) and have been set the task of finding the Oracle. Gozz has given you a copy of the minutes dating back years and an array of clever words that an Oracle would totally use. He suggested you search the minutes for the longest clever words used and report back.

A word is considered to occur in the minutes regardless of the case. So kek would match kEK. Also, the Oracle can be really sneaky and a hide a word inside another. For example no would match Not. Also, the oracle will never use words with punctuation, so dont should not match don't, but it will match dont., since the . is outside the word. In short, a word used by the Oracle must occur somewhere as a substring.

Input Specification

The first line contains the entire history of the UCC minutes, and has between 1 and 100 characters inclusive. The second line contains an integer \(N\) (\(1\leq N \leq 10\)) denoting the number of lines to follow. The next \(N\) lines contain a single word, which is a lowercase alphabetic string with no spaces.

Output Specification

Output the longest clever word that occurs in the minutes. If there are multiple longest words, output each on their own line in the order they occurred in the input. If there are none, do not output anything.

Sample Input 1
If computers get too powerful, we can organize them into committees.  That'll do them in.
Sample Output 1


Sample Input 2
The best thing about a boolean is even if you're wrong, you are only off by a bit.
Sample Output 2



  • 0
    Levi  commented on June 4, 2018, 2:18 p.m.

    Nvm got it

  • 0
    Levi  commented on June 4, 2018, 12:36 p.m.

    Any hints as to why my incredibly fragile code is failing the last test case? ( ͡ಥ ͜ʖ ͡ಥ)