
KMP
文章平均质量分 57
永夜莫明
菜是原罪
展开
-
kmp入门及模板
KMP算法主要用于解决字符串的匹配问题。即给定两个字符串text与pattern,需要判断pattern是否是text的子串。假设text的长度为n,pattern的长度为m,那么用暴力搜索的算法解决该问题需要的时间复杂度为O(m*n)。而KMP算法需要的时间复杂度仅为O(m+n)。Knuth、Morris、Pratt是发明这个算法的三位科学家。KMP算法最浅显理解——一看就明白 htt...原创 2019-02-03 19:40:27 · 235 阅读 · 0 评论 -
String Problem (最大最小表示法模板)
https://cn.vjudge.net/problem/HDU-3374Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings:Strin...原创 2019-08-06 00:35:04 · 396 阅读 · 1 评论 -
Number Sequence (KMP匹配模板)
https://cn.vjudge.net/problem/HDU-1711Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find...原创 2019-08-05 21:46:47 · 155 阅读 · 0 评论 -
Seek the Name, Seek the Fame(KMP next数组)
The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek th...原创 2019-02-24 15:19:48 · 159 阅读 · 0 评论 -
怪盗基德的挑战书 (kmp+dp)
在树最美丽的那天,当时间老人再次把大钟平均分开时,我会降临在灯火之城的金字塔前,带走那最珍贵的笑容。”这是怪盗基德盗取巴黎卢浮宫的《蒙娜丽莎的微笑》这幅画时,挑战书上的内容。 但这次,怪盗基德的挑战书上出现了一串串小写字母“aaab sdfeeddd...”。柯南以小学生的眼睛,超凡高中生的头脑,快速统计各种字母频率,字符串长度,并结合挑战书出现的时间等信息,试图分析怪盗基德的意图。最...原创 2019-02-17 16:07:59 · 671 阅读 · 0 评论 -
Making Huge Palindromes (回文串,kmp)
题目链接:https://vjudge.net/problem/LightOJ-1258A string is said to be a palindrome if it remains same when read backwards. So, 'abba', 'madam' both are palindromes, but 'adam' is not.Now you are give...原创 2019-02-03 20:58:44 · 321 阅读 · 0 评论 -
Power Strings(循环节)
题目链接:https://vjudge.net/problem/POJ-2406Given 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 concatenation a...原创 2019-02-03 20:20:15 · 256 阅读 · 0 评论 -
Period(循环节)
题目链接:https://vjudge.net/problem/HDU-1358For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is ...原创 2019-02-03 20:10:30 · 416 阅读 · 0 评论 -
Cyclic Nacklace(kmp求循环节入门)
题目链接:https://vjudge.net/problem/HDU-3746CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he i...原创 2019-02-03 20:03:31 · 345 阅读 · 0 评论 -
How many(最小表示法将串唯一表示,set去重)
https://cn.vjudge.net/problem/HDU-2609Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell meHow many kinds of necklaces total have.(if two necklaces can equal...原创 2019-08-06 00:46:32 · 277 阅读 · 0 评论