KMP
大白QQly成长日记
小白自远方来
展开
-
HDU 3336-Count the string(kmp+DP)
Problem Description 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-empty prefixes of this string. F...原创 2019-01-25 19:14:09 · 260 阅读 · 0 评论 -
HDU1686 P3375 HDU1711(kmp入门)
一直不理解kmp,近期学习一下。 简单来说kmp算法就是利用匹配串的自身匹配进行预处理,从而使暴力匹配的O(n*m)降到了O(n+m). 但这句话是很绕的,什么是自身匹配,又是怎么预处理。 我们先来考虑一下对暴力匹配的优化以便于理解。(个人理解,可能有误) 假如有一个前提:匹配串中的字符全部唯一。那么在进行暴力匹配时就可以跳过已匹配部分。例如: 总串:abdefghabc 匹配串:a...原创 2019-01-21 15:49:45 · 262 阅读 · 0 评论