Live2d Test Env

随笔分类 -  字符串处理——kmp

摘要:题意:给定字符串S,A,B。现在让你对S进行切割,使得每个切割出来的部分在[A,B]范围内,问方案数。 思路:有方程,dp[i]=Σ dp[j] (S[j+1,i]在合法范围内)。 假设M和N的最长公共前缀为长度是LCP,那么字符串M>=字符串N的条件是 LCP=|N|或者(LCP<|N|&&M[l 阅读全文
posted @ 2019-08-31 20:31 nimphy 阅读(253) 评论(0) 推荐(0) 编辑
摘要:不知道写什么。。。 阅读全文
posted @ 2019-02-19 12:51 nimphy 阅读(613) 评论(0) 推荐(0) 编辑
摘要:Sample Input Sample Output 给定一个数字字符串S,如果一个数字字符串(只包含0-9,可以有前导0)中出现且只出现1次S,我们就称这个字符串是好的。 例如假设S=666,则1666、03660666是好的,6666、66、123不是好的;假设S=1212,则01212、121 阅读全文
posted @ 2019-01-07 18:09 nimphy 阅读(364) 评论(0) 推荐(0) 编辑
摘要:题目描述 一个串T是S的循环节,当且仅当存在正整数k,使得S是T k Tk (即T重复k次)的前缀,比如abcd是abcdabcdab的循环节。给定一个长度为n的仅由小写字符构成的字符串S,请对于每个k(1<=k<=n),求出S长度为k的前缀的最短循环节的长度per i peri 。字符串大师小Q觉 阅读全文
posted @ 2018-11-11 21:28 nimphy 阅读(178) 评论(0) 推荐(0) 编辑
摘要:One day Silence is interested in revolving the digits of a positive integer. In the revolving operation, he can put several last digits to the front o 阅读全文
posted @ 2018-09-29 12:05 nimphy 阅读(215) 评论(0) 推荐(0) 编辑
摘要:After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a 阅读全文
posted @ 2018-08-16 14:55 nimphy 阅读(253) 评论(0) 推荐(0) 编辑
摘要:我们定义2个字符串的相似度等于两个串的相同前缀的长度。例如 "abc" 同 "abd" 的相似度为2,"aaa" 同 "aaab" 的相似度为3。 给出一个字符串S,计算S同他所有后缀的相似度之和。例如:S = "ababaa",所有后缀为: ababaa 6 babaa 0 abaa 3 baa 阅读全文
posted @ 2018-06-02 22:51 nimphy 阅读(537) 评论(0) 推荐(0) 编辑
摘要:先放代码。 下标从1开始。 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N = 101010; int next[N],extand[N]; char S[N],T[N]; 阅读全文
posted @ 2018-03-07 16:37 nimphy 阅读(200) 评论(0) 推荐(0) 编辑
摘要:描述 给定两个字符串A和B,请你求出字符串A最少重复几次才能使得B是A的子串。 例如A="hiho",B="hohihohi"。则A重复3次之后变为"hihohihohiho",这时B是A的子串。 输入 输入包含多组数据。 第一行包含一个整数T,表示数据组数。 (1 ≤ T ≤ 5) 对于每组数据, 阅读全文
posted @ 2018-02-17 21:10 nimphy 阅读(370) 评论(0) 推荐(0) 编辑
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate 阅读全文
posted @ 2017-12-30 21:33 nimphy 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like tradema 阅读全文
posted @ 2017-12-13 18:02 nimphy 阅读(272) 评论(1) 推荐(0) 编辑
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate 阅读全文
posted @ 2017-12-10 14:39 nimphy 阅读(455) 评论(0) 推荐(0) 编辑
摘要:Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 sec 阅读全文
posted @ 2017-12-09 12:54 nimphy 阅读(358) 评论(0) 推荐(0) 编辑
摘要:It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-emp 阅读全文
posted @ 2017-10-09 12:23 nimphy 阅读(166) 评论(0) 推荐(0) 编辑
摘要:老套路: 阅读全文
posted @ 2017-10-08 19:30 nimphy 阅读(207) 评论(0) 推荐(0) 编辑
摘要:是本来想今天写下后缀数组,谁知明天要交高数作业,还有大物视频,英语视频blablabla。。。 赶啊。。。。然后忍不住写了两个kmp水题 每天都要进步 阅读全文
posted @ 2017-10-08 18:57 nimphy 阅读(177) 评论(0) 推荐(0) 编辑
摘要:求a串中有多少个b串,可重复使用。 KMP: 阅读全文
posted @ 2017-10-08 18:30 nimphy 阅读(169) 评论(0) 推荐(0) 编辑
摘要:第一次写字典树,也不晓得写得好不好 阅读全文
posted @ 2017-09-28 16:57 nimphy 阅读(132) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示