poj1159 【LCS】】的更多相关文章

思路: 滚动数组; 贴一发挫code- #include <iostream> #include <cstdio> #include <string.h> #include <algorithm> using namespace std; typedef __int64 LL; const int N=5e3+10; int dp[3][N]; int k,n; char s[N]; char s1[N]; char s2[N]; int main() {…
P4303 [AHOI2006]基因匹配 标签(空格分隔): 考试题 nt题 LCS优化 [题目] 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球上只有4种),而更奇怪的是,组成DNA序列的每一种碱基在该序列中正好出现5次!这样如果一个DNA序列有N种不同的碱基构成,那么它的长度一定是5N. 卡卡醒来后向可可叙述了这个奇怪的梦,而可可这些日子正在研究生物信息学中的基因匹配问题,于是他决定为这个奇怪星球上的生物写一个简单的DNA匹配程序. 为了…
题目链接:https://vjudge.net/problem/POJ-2250 题目大意:给出n组case,每组case由两部分组成,分别包含若干个单词,都以“#”当结束标志,要求输出最长子序列. #include <iostream> #include <string> using namespace std; ], b[], ans[]; ][], num[][]; void LCSLength() { memset(dp, , sizeof(dp)); memset(num…
任意门:http://poj.org/problem?id=1159 解题思路: LCS + 滚动数组 AC code: #include <cstdio> #include <iostream> #include <algorithm> #define INF 0x3f3f3f3f #define LL long long using namespace std; ; char a[MAXN], b[MAXN]; ][MAXN]; int main() { int l…
题意: 求最长公共子序列,并且这个子序列是字典序最小. 思路: LCS附一个值,dp[i][j].first代表以i,j的LCS的长度,dp[i][j].second代表LCS结尾元素,然后利用路径输出就好了: 竖着传就是1,横着就是-1,斜对角就是0: 然后就wa掉了...因为单一的判断结尾肯定不行啊,要判断这个满足的串: 138885777 15738 所以second为整个串:所以不需要路径记录了: 直接输出dp[L1][L2].second就好了: #include <bits/stdc…
Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 28494    Accepted Submission(s): 12735 Problem Description A subsequence of a given sequence is the given sequence with some e…
嘤嘤嘤,我又来了,刚A完就写,这个沙雕题有丶恶心.                  ???时间4.11发现所有表情包都莫得了 题目: In an n×n chessboard, Prince and Princess plays a game. The squares in the chessboard are numbered 1, 2, 3, . . . , n∗n, as shown below:   Prince stands in square 1, make p jumps and…
Common Subsequence Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43132   Accepted: 17472 Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..…
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7823    Accepted Submission(s): 4033 Problem Description A group of researchers are designing an experiment to test the IQ of a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1503 题目大意: 给两个字符串,组成一个长度尽可能小的字符串,它包含上述两个字符串,且原字符串中的字符在该串中的相对位置不变. Sample Input apple peach ananas banana pear peach   Sample Output appleach bananas pearch   解题思路:要结合样例来理解题意,本题主要难在如何输出题目要求字符串,这就需要我们仔细研究样…