cswork / OA打开练习工作台

AmazonOA #338

Amazon Review Score

估计中等可在线判题

考点(AI 标注)双指针滑窗字符串

Find the longest contiguous substring of the review that contains no banned word. Matching ignores case, and a banned word can appear at any position; matching is not limited to whole words. If there is no non-empty valid substring, the answer is 0.

输入格式

The first line contains review, the second line contains the number of banned words, and each following line contains one banned word. Original bounds: review has length 1..100000 and contains only ASCII uppercase and lowercase letters; there are 1..10 words, each consisting of 1..10 lowercase letters.

输出格式

Output a single integer, the answer.

样例 1

输入:

GoodProductButScrapAfterWash
2
crap
odpro

输出:

15

样例 2

输入:

Aa
1
a

输出:

0

样例 3

输入:

ExtremeValueForMoney
2
tuper
douche

输出:

20

样例说明

In the first original example, the correct longest fragment is dProductButScra, of length 15; the dProductButScu listed separately by the source is not a fragment of the original string. The answers to the other public examples are 0 and 20.