其他分享
首页 > 其他分享> > Repetition (二分+hash+map)

Repetition (二分+hash+map)

作者:互联网

 Repetition
time limit per test3 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Walk_alone loves repetition! He has a lot to say, and he may repeat some information in every sentence (represented as n strings S1,S2,…,Sn) he says. Since such information could be important, his teammates want to extract a substring which appears in every sentence for at least k times. However, some information (represented as string T) is so sensitive that they would not allow it to appear in the information. It is hard to find out the longest information they can extract, so they ask you for help.

Formally, you are given n strings S1,S2,…,Sn and a pattern T. Your task is to find the length of the longest string which appears in every Si (1≤i≤n) for at least k times, and does not have T as its continuous substring.

Input
The first line contains two integers n (1≤n≤105) and k (1≤k≤105).

The i-th of the following n lines contains a string Si (|Si|≥1,∑ni=1|Si|≤106).

The last line contains a string T (1≤|T|≤105).

It is guaranteed that all strings contain only lowercase English letters.

Output
Output an integer representing the answer. If such string does not exist, output −1 instead.
View problem

思路:

 

标签:map,hash,string,information,Si,every,they,Repetition
来源: https://www.cnblogs.com/Lamboofhome/p/16358670.html