cswork / OA打开练习工作台

Capital OneOA #12

Recipes — Is Each Recipe a Prep-list Combination?

估计中等可在线判题

考点(AI 标注)字符串

You are given ingredient strings ingredients and several recipe strings. A recipe is a prep-list combination if it can be split into one or more contiguous non-empty pieces, each exactly equal to some string in ingredients. Decide this for each recipe.

输入格式

The first line contains n r (1≤n,r≤200000), followed by n lines of non-empty lowercase ingredient names, then r lines of non-empty lowercase recipe strings. This site's supplementary ranges: each ingredient has length ≤100, and the total number of ingredient characters is ≤200000; the total number of recipe characters is ≤100000, and maximum ingredient length × total recipe characters ≤10^7. The input format and performance ranges above are this site's supplement.

输出格式

Output YES or NO for each recipe in input order, separated by spaces.

样例 1

输入:

3 5
flour
sugar
eggs
floursugar
random
flour
sugarflour
sugareggs

输出:

YES NO YES YES YES

样例 2

输入:

2 3
a
ab
ab
aba
b

输出:

YES YES NO

样例 3

输入:

1 3
xy
xy
xyxy
x

输出:

YES YES NO