09 2015 档案

zoj3822-Domination (概率dp)
摘要:题意:给你n*m的棋盘,每天选择的一个空的方格放一个棋子,求使棋盘的每行每列都至少有一个棋子的天数期望。分析:先想状态,要使每行每列都至少一个,考虑前i行j列,能放得就是i行j列里面的或第i+1行j列或第i行j+1列或第i+1行j+1列,再用一维k表示已经放的棋子个数。求期望逆推dp[0][0][0... 阅读全文

posted @ 2015-09-08 22:37 积跬步、至千里 阅读(233) 评论(0) 推荐(0)

HDU5045-Contest(状压dp)
摘要:题意:有n个学生,m道题,给出每个同学解出m个问题的概率,在解题过程中每个学生的解题数的差不大于1,求最大能解出题目数的期望分析:n很小,知道用状压,但是比赛没做出来(脑子太死了,有一个限制条件在解题过程中每个学生的解题数的差不大于1,哎,关键在这句话,那就是说,在解题过程中必须先是每人解出一道题目... 阅读全文

posted @ 2015-09-04 20:12 积跬步、至千里 阅读(160) 评论(0) 推荐(0)

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 积跬步、至千里 阅读(221) 评论(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 积跬步、至千里 阅读(201) 评论(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 积跬步、至千里 阅读(125) 评论(0) 推荐(0)

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

posted @ 2015-09-03 22:27 积跬步、至千里 阅读(124) 评论(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 积跬步、至千里 阅读(126) 评论(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 积跬步、至千里 阅读(633) 评论(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 积跬步、至千里 阅读(138) 评论(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 积跬步、至千里 阅读(127) 评论(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 积跬步、至千里 阅读(128) 评论(0) 推荐(0)

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

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

POJ 3744 Scout YYF I (概率dp+矩阵快速幂)
摘要:题意:一条路上,给出n地雷的位置,人起始位置在1,向前走一步的概率p,走两步的概率1-p,踩到地雷就死了,求安全通过这条路的概率。分析:如果不考虑地雷的情况,dp[i],表示到达i位置的概率,dp[i]=dp[i-1]*p+dp[i-2]*(1-p),要想不踩地雷求出到达地雷位置的概率tmp,1-t... 阅读全文

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

Maximum Random Walk(概率dp)
摘要:题意:走n步,给出每步向左走概率l,向右走概率r,留在原地的概率 1-l-r,求能达到的最远右边距离的期望。分析;开始按期望逆求的方式分析,但让求的就是右边界没法退,懵了一会,既然逆着不能求,就先正着求概率,再根据期望的定义来求,试试行吗,想了想状态,dp[i][j][k],表示走了i步当前位置是j... 阅读全文

posted @ 2015-09-01 22:40 积跬步、至千里 阅读(349) 评论(0) 推荐(0)

Codeforces 167B Wizards and Huge Prize(概率dp)
摘要:题意:n个人,开始有一个容量为k得背包,击败一个人背包可以获得一定容量或得到一个财富(放入背包内),给出击败每个人的概率,求至少击败l个人,且背包容量大于获得的总财富值的概率分析:状态好确定,dp[i][j][k]表示前i个人击败j个背包容量是k是的概率,求概率正推,要注意这时背包容量能为负,我们把... 阅读全文

posted @ 2015-09-01 22:28 积跬步、至千里 阅读(316) 评论(0) 推荐(0)

导航