#P2031. 脑力达人之分割字串
脑力达人之分割字串
Description
You are given a string. You may split this string into segments. For example, abcvsdaas can be split as abc|vs|d|aas. You are also given a dictionary. Each segment after splitting must contain at least one word from the dictionary as a substring. What is the maximum number of segments you can obtain?
Input Format
- The first line contains a string.
- The second line contains a positive integer , the number of strings in the dictionary.
- The next lines each contain a string , representing a dictionary string.
Output Format
Output one integer, the maximum number of segments.
asdsd
3
as
sd
ds
2
Hint
Special case: If the original string cannot be split, output .
Constraints: For of the testdata, . For of the testdata, . Here, denote the lengths of string and .
Translated by ChatGPT 5
京公网安备 11011102002149号