【Codeforces 86C】Genetic engineering
Codeforces 86 C
题意:给\(m\)个串,要构造长度为\(n\)的串,而且必须由这些模式串们覆盖(可以重复),问可以构造多少种。
思路:首先构造AC自动机,然后\(dp(i,j,k)\)表示现在到了要构造的串的第\(i\)位,匹配到了AC自动机的第\(j\)个节点,最后\(k\)位还未被覆盖的种数。
转移方程:如AC自动机的第\(j\)个节点是某个模式串的结尾且这个模式串的长度大于\(k\),那么
\(dp(i+1,nxt_j^c,0)+=dp(i,j,k)\),否则\(dp(i+1,nxt_j^c,k+1)+=dp(i,j,k)\)
【Codeforces 86C】Genetic engineering的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【22.70%】【codeforces 591C】 Median Smoothing
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
随机推荐
- HDU5543(SummerTrainingDay03-O DP)
Pick The Sticks Time Limit: 15000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others ...
- php 对象转数组
//参考网上 但是别人给的方法有错误的地方public function eleme_callback(){ $res = (object) array('1' => 'foo'); $data ...
- Python 单例设计模式
class Foo: def __init__(self, name, age): self.name = name self.age = age def show(self): print(self ...
- JS之用ES6 Promise解决回调地狱(这里以小程序为例)
首先 写一个请求的方法,如: /** * 银行窗口 * 你需要给我提供相关的相关参数我帮你提交到服务器上 * 我会给你一个等待区的编号给你 你去等待区等待,我处理完成会去等待区通知你 * @param ...
- vue中使用axios(异步请求)和mock.js 模拟虚假数据
一.使用axios 1.安装 npm install --save axios 2.引用 import Axios from 'axios' Vue.prototype.Axios = Axios 二 ...
- Installing Language Tool in TexStudio
This is a recent and more detailed solution for Windows users. Make sure the last version of TeXstud ...
- Centos 6.8 系统升级默认的Python版本
1.编译安装python2.7 # wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz # Python-2.7.12.tg ...
- How to deploy kotlin in androidstudio?
Kotlin is a good language,more playable than Java.So how do we deploy kotlin? First,install the kotl ...
- Fiddler抓包使用教程-基本功能介绍
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/72932886 本文出自[赵彦军的博客] Fiddler 基本页面 会话列表功能介绍 ...
- scrapy系列(四)——CrawlSpider解析
CrawlSpider也继承自Spider,所以具备它的所有特性,这些特性上章已经讲过了,就再在赘述了,这章就讲点它本身所独有的. 参与过网站后台开发的应该会知道,网站的url都是有一定规则的.像dj ...