ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Repetition (二分+hash+map)

2022-06-09 11:34:07  阅读:191  来源: 互联网

标签:map hash string information Si every they Repetition


 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

思路:

  • 二分长度+然后利用hash+map(字符串通常用)看出现了几次,
  • 利用hash的好处是,O1就可以得到字串,
  • ............

 

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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有