kmp
日月火山
这个作者很懒,什么都没留下…
展开
-
牛客多校第九场 Niuniu is practicing typing.(kmp优化)
链接:https://www.nowcoder.com/acm/contest/147/F 来源:牛客网 Niuniu is practicing typing. Given n words, Niuniu want to input one of these. He wants to input (at the end) as few characters (without backspa...原创 2018-08-17 11:05:19 · 340 阅读 · 0 评论 -
HDU - 3336 (Next数组+dp)
Count the string HDU - 3336 题意:给定字符串s,求s的所有前缀作为子串在s中出现的次数和。 思路:考虑dp dp[i] 表示以第i个字母结尾的所有后缀与s的前缀的匹配次数。 按照最暴力的想法来做的话,肯定我得枚举以第i个字母结尾的每个后缀。 其实也可以这样想:dp[i] 等于s(0,i)最长后缀对结果的贡献加1。然后又kmp里Next数组可以得知,...原创 2018-11-07 21:24:09 · 207 阅读 · 0 评论