Created
October 20, 2016 16:03
-
-
Save ethernet8023/41154e6decaab2cd937db5ba65ef918d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def doThing(dic, words): | |
| charsNeeded = [doesIntersect(dic, word) for word in words] | |
| A1 = "Yes" if all(charsNeeded) else "No" | |
| A2 = max(*charsNeeded) | |
| return A1 + " " + str(A2) | |
| def doesIntersect(dic, word): | |
| dic = list(dic) | |
| charsNeeded = 0 | |
| for char in word: | |
| if char in dic: | |
| dic.remove(char) | |
| else: | |
| charsNeeded += 1 | |
| return True if charsNeeded == 0 else charsNeeded | |
| num_cases = int(input()) | |
| for i in range(num_cases): | |
| num_words, num_strings = [int(x) for x in input().split(' ')] | |
| words = [input() for _ in range(num_words)] | |
| strings = [input() for _ in range(num_strings)] | |
| validatedStrings = [doThing(st, words) for st in strings] | |
| [print(st) for st in validatedStrings] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment