
ACM_动态规划_LCS
文章平均质量分 76
kthsdwwl
这个作者很懒,什么都没留下…
展开
-
poj 1458 Common Subsequence
题目链接: 点击打开链接 题目大意: 最长公共子序列 代码: #include #include #include #include using namespace std; const int maxn = 10000; string a, b; int dp[maxn][maxn]; void lcs() { int x = a.length(), y原创 2013-12-16 15:42:35 · 485 阅读 · 0 评论 -
poj 2250 Compromise
题目链接: 点击打开链接 题目大意: 找出两个单词序列的最长公共部分 思路: 动态规划,最长公共子序列 分析: 最长公共子序列问题,要输出子序列。子序列的每个单元不是字符而是单词。增加一个二维数组记录路径,0表示数据来自dp[i-1][j-1],1表示数据来自dp[i-1][j], 2表示数据来自dp[i][j-1]。最后递归输出就行了。 代码: #inc原创 2013-12-16 16:42:31 · 428 阅读 · 0 评论