#P1381. 单词背诵
单词背诵
Description
Reimu has words she wants to memorize, and she plans to remember them through a contiguous segment of an article.
The article consists of words. She wants to find a contiguous segment in the article that contains as many of her target words as possible, counting only distinct target words within the segment (duplicates count as one). Among all segments that contain the maximum number of target words, she also wants the segment to be as short as possible, so that she can spend the least time learning as many words as she can.
Input Format
The first line contains an integer , followed by lines, each of which is a string of length at most , representing a target word to memorize.
Then an integer follows, and then lines, each of which is a string of length at most , representing a word in the article.
Output Format
Output two lines. The first line is the maximum number of target words contained in any contiguous segment of the article. The second line is the length of the shortest contiguous segment that contains this maximum number of target words.
3
hot
dog
milk
5
hot
dog
dog
milk
hot
3
3
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号