上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页

2015年9月3日

HNU 13108-Just Another Knapsack Problem (ac自动机上的dp)

摘要: 题意:给你一个母串,多个模式串及其价值,求用模式串拼接成母串(不重叠不遗漏),能获得的最大价值。分析:ac自动机中,在字典树上查找时,用dp,dp[i]拼成母串以i为结尾的子串,获得的最大价值,dp[i]=max(dp[i],dp[i-len]+val[tmp])。,len是模式串的长度,val[t... 阅读全文

posted @ 2015-09-03 22:46 积跬步、至千里 阅读(209) 评论(0) 推荐(0) 编辑

LightOJ 1427 -Repository(ac自动机)

摘要: 题意:求每个模式串在母串中出现的次数#include #include #include #include #include #include #include #include #include #include #include #include #include #include #inclu... 阅读全文

posted @ 2015-09-03 22:35 积跬步、至千里 阅读(195) 评论(0) 推荐(0) 编辑

HDU 3065 AC自动机

摘要: 题意:给多个模式串一个母串,求个模式串在母串中出现的次数。#include #include #include #include #include #include #include #include #include #include #include #include #include #inc... 阅读全文

posted @ 2015-09-03 22:29 积跬步、至千里 阅读(117) 评论(0) 推荐(0) 编辑

HDU 2896-病毒侵袭(ac自动机)

摘要: 题意:给定多个模式串,每给一个母串,输出包含模式串的编号,最后输出包含模式串的母串的数量。分析:ac自动机模板#include #include #include #include #include #include #include #include #include #include #incl... 阅读全文

posted @ 2015-09-03 22:27 积跬步、至千里 阅读(116) 评论(0) 推荐(0) 编辑

HDU 3695-Computer Virus on Planet Pandora(ac自动机)

摘要: 题意:给一个母串和多个模式串,求模式串在母串后翻转后的母串出现次数的的总和。分析:模板题/*#include #include #include #include #include using namespace std;const int maxnode = 250*1000+10000;cons... 阅读全文

posted @ 2015-09-03 22:05 积跬步、至千里 阅读(114) 评论(0) 推荐(0) 编辑

hdu 2594-Simpsons’ Hidden Talents(KMP)

摘要: 题意:给你两个串a,b,求既是a的前缀又是b的后缀的最长子串的长度。分析:很自然的想到把两个串连接起来,根据KMP的性质求即可#include #include #include #include #include #include #include #include #include #inclu... 阅读全文

posted @ 2015-09-03 21:50 积跬步、至千里 阅读(621) 评论(0) 推荐(0) 编辑

hdu 2087-剪花布条(KMP)

摘要: 题意:求文本串最多可以分成几个模式串。分析:KMP#include #include #include #include #include #include #include #include #include #include #include #include #include #include... 阅读全文

posted @ 2015-09-03 21:43 积跬步、至千里 阅读(132) 评论(0) 推荐(0) 编辑

hdu 3746 Cyclic Nacklace(KMP)

摘要: 题意:求最少需要在后面补几个字符能凑成两个循环。分析:最小循环节的应用,i-next[i]为最小循环节。#include #include #include #include #include #include #include #include #include #include #include... 阅读全文

posted @ 2015-09-03 21:38 积跬步、至千里 阅读(119) 评论(0) 推荐(0) 编辑

hdu 3336 count the string(KMP+dp)

摘要: 题意:求给定字符串,包含的其前缀的数量。分析:就是求所有前缀在字符串出现的次数的和,可以用KMP的性质,以j结尾的串包含的串的数量,就是next[j]结尾串包含前缀的数量再加上自身是前缀,dp[i]表示以i为结尾包含前缀的数量,则dp[i]=dp[next[i]]+1,最后求和即可。#include... 阅读全文

posted @ 2015-09-03 21:34 积跬步、至千里 阅读(117) 评论(0) 推荐(0) 编辑

2015年9月2日

HDU 4749-Parade Show(KMP变形)

摘要: 题意:给出一个母串和一个模式串求母串中最多能分成最大的子串数(每个字串中的各个数字的大小关系和模式串相同)分析:KMP变形匹配规则变一下即可,用当前数字和下个数字的差表示,大小关系方便匹配#include #include #include #include #include #include #i... 阅读全文

posted @ 2015-09-02 15:59 积跬步、至千里 阅读(143) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页

导航