HDU 1159 最长公共子序列】的更多相关文章

Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32693    Accepted Submission(s): 14786 Problem Description A subsequence of a given sequence is the given sequence with some el…
Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 53443    Accepted Submission(s): 24607 Problem Description A subsequence of a given sequence is the given sequence with some el…
Description A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number of characters to be inserted into t…
题意:先给两个水果的名字然后得出一个最短的序列包含这两个词. 思路:我一开始的思路是先求出最长公共子序列,然后做一些处理将其他的部分输出来:两种水果的字符串和最长公共子序列的字符串这三个字符串做对比,当他们三个相同的时候将最长公共子序列里面的字符去掉,如果不相同,将水果中的字符串中的字符去掉直到相同为止,不过网上用了一个好像比较方便的方法,在输出最长公共子序列的路径时候也能输出其他的字符(利用递归回溯). 注意:网上有一个求最长公共子序列的过程的二维的图值得一看,方便理解!! 我的方法: //最…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18201    Accepted Submission(s): 7697 Problem Description A subsequence of…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4681 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> #include<vector> using namespace std; ; const int INF =…
/* 给两个串a,b.输出一个最短的串(含等于a的子序列且含等于b的子序列) */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; int dp[maxn][maxn],path[maxn][maxn]; int len,len1,len2; char text[maxn],a[maxn],b[maxn]; void getpath() { int n=len…
 /*Common Subsequence A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a subsequence of X if there exist…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 题意: 求最长公共子序列. 题解: (LCS模板题) 表示状态: dp[i][j] = max len of LCS a串匹配到第i位,b串匹配到第j位,此时的最长公共子序列长度. 如何转移: 首先,一个明显的决策是,如果a[i] == b[j],那么此一定要匹配.(贪心) 所以分两种情况: (1)a[i] == b[j]:dp[i][j] = dp[i-1][j-1] + 1 (2)a[i]…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159 Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37551    Accepted Submission(s): 17206 Problem Description A subsequence of…