DNA Sequence   Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For example, if a animal's DNA sequence contains segment ATC then it may mean that the a…
题意:给定n个不能出现的模式串,给定一个长度m,要求长度为m的合法串有多少种. 思路:用AC自动机,利用AC自动机上的节点做矩阵乘法. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<algorithm> #include<queue> #define MOD 100000 ];…
DNA Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9899   Accepted: 3717 Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For exa…
DNA Sequence Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For example, if a animal's DNA sequence contains segment ATC then it may mean that the ani…
DNA Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11860   Accepted: 4527 Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For ex…
DNA Sequence 题意:DNA的序列由ACTG四个字母组成,如今给定m个不可行的序列.问随机构成的长度为n的序列中.有多少种序列是可行的(仅仅要包括一个不可行序列便不可行).个数非常大.对100000取模. 思路:推荐一个博客,讲的很清楚. 这样的题目.n非常大,首先想到的就是用矩阵来优化.那么怎样构造转移方程呢:首先建立一棵Trie,然后依照AC自己主动机的方式构造fail指针,然后会发现.当一个状态分别加入ACTG之后,会得到还有一个状态. (详细解释见代码) 代码: /* ID:…
QAQ 做完禁忌 又做过文本生成器 这道题就是个水题啦 首先转移方程还是文本生成器的转移方程 但是注意到L很大,但是节点数很小 转移都是固定的,所以我们可以用AC自动机来构造转移矩阵 之后进行矩阵乘法就可以了 顺便提一句,模数是10^5,相乘会爆int 我为了省点常数自信开int,结果WA了两发QAQ #include<cstdio> #include<iostream> #include<algorithm> #include<cstdlib> #incl…
DNA Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11860   Accepted: 4527 Description It's well known that DNA Sequence is a sequence only contains A, C, T and G, and it's very useful to analyze a segment of DNA Sequence,For ex…
链接:http://poj.org/problem?id=2778 题意:给定不超过10串,每串长度不超过10的灾难基因:问在之后给定的长度不超过2e9的基因长度中不包含灾难基因的基因有多少中? DNA:只含'A','T','C','G'四种字符: 思路:这并不是很裸的ac自动机..没有很明显的文本串匹配过程,但是我们能过通过对灾难基因建好Trie,在跑一下失配边时需要初始化状态转移矩阵了: 状态矩阵:每一次都可以往下一个位置走四个方向,但是要求不能走到单词节点. (mat[i][j]) ^n:…
题目链接:http://poj.org/problem?id=2778 题意:有m种DNA序列是有疾病的,问有多少种长度为n的DNA序列不包含任何一种有疾病的DNA序列.(仅含A,T,C,G四个字符) 思路:Trie图的状态转移,用矩阵mat[i][j]来表示从结点i到j只走一步有几种走法,那么mat的n次幂就表示从结点i到j走n步有几种走法,题目要求解的就是从头节点走n步且不包含危险结点的走法. mat = mat^n   ans = (mat[0][0] + mat[0][1] + ...…