poj 1795 DNA Laboratory】的更多相关文章

DNA Laboratory Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 2892   Accepted: 516 Description Background Having started to build his own DNA lab just recently, the evil doctor Frankenstein is not quite up to date yet. He wants to extra…
[题目链接] http://poj.org/problem?id=1795 [题目大意] 给出n个字符串,求一个最小长度的串,该串包含给出的所有字符串. 要求长度最小且字典序最小. [题解] dp[i][s]表示包括s集合字符串的第i个字符串为开头的最小值 从后往前贪心得到最小值,然后从前往后搜索得出最小字典序的答案 [代码] #include <iostream> #include <cstring> #include <algorithm> #include <…
题意:给定 n 个 字符串,让你构造出一个最短,字典序最小的字符串,包括这 n 个字符串. 析:首先使用状压DP,是很容易看出来的,dp[s][i] 表示已经满足 s 集合的字符串以 第 i 个字符串结尾,他很容易就求得最短长度,但是这个字符串怎么构造呢, 由于要字典序最小,所以就不好搞了,挺麻烦的,所以我们利用贪心的思路,我们可以这样定义,dp[s][i] 表示已经满足 s 集合的字符串以 第 i 个字符串开头, 从后向前放,状态转移方程为:dp[s|(1<<i)][i] = min{ dp…
DNA Laboratory Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 1425   Accepted: 280 Description Background Having started to build his own DNA lab just recently, the evil doctor Frankenstein is not quite up to date yet. He wants to extra…
题目链接:http://poj.org/problem?id=1007 本题属于字符串排序问题.思路很简单,把每行的字符串和该行字符串统计出的字母逆序的总和看成一个结构体.最后把全部行按照这个总和从小到大排序即可. #include <iostream> #include <algorithm> using namespace std; struct DNA { ]; int count; } d[]; int cmp(DNA a, DNA b) { return a.count…
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…
链接: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] + ...…
DNA Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9889   Accepted: 3712 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 Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 77786   Accepted: 31201 Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For ins…