LIS(Longest Increasing Subsequence)最长上升(不下降)子序列,有两种算法复杂度为O(n*logn)和O(n^2)。在上述算法中,若使用朴素的顺序查找在 D1..Dlen查找,由于共有O(n)个元素需要计算,每次计算时的复杂度是O(n),则整个算法的时间复杂度为O(n...
分类:
其他好文 时间:
2014-09-24 08:14:46
阅读次数:
218
http://blog.csdn.net/yysdsyl/article/details/4226630 1 public class Main { 2 3 /** 4 * longest common subsequence 5 * @param args 6 ...
分类:
其他好文 时间:
2014-09-22 18:07:52
阅读次数:
203
package 字符串2;public class TestString {public static void main(String[] args) { String str = "Returns a new character sequence that is a subsequence of...
分类:
其他好文 时间:
2014-09-20 17:35:59
阅读次数:
182
Distinct Subsequences
Total Accepted: 15484 Total
Submissions: 62324My Submissions
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of ...
分类:
其他好文 时间:
2014-09-16 22:09:51
阅读次数:
204
最长公共子序列LCS有模板的吧#include#include#includeusing namespace std;int i,j,dp[1000][1000],len1,len2;char a[1000],b[1000];void LCS(){ memset(dp,0,sizeof(dp)...
分类:
其他好文 时间:
2014-09-10 22:18:01
阅读次数:
167
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4991
Ordered Subsequence
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 221 Accepted Su...
分类:
其他好文 时间:
2014-09-10 15:56:40
阅读次数:
145
问题描述:序列X={x1,x2,…,xn},Y={y1,y2,…,yn},当Z={z1,z2…,zn}是X的严格递增下标顺序(可以不连续)的子集,也是Y的严格递增下标顺序(可以不连续)的子集,则Z是X和Y的公共子序列。例如X={A,B,C,B,D,A,B},Y={B,D,C,A,B,A},{B,C,A}、{B,C,B,A}、{B,D,A,B}都是X和Y的公共子序列。其中最长的公共子序列叫做Long...
分类:
其他好文 时间:
2014-09-10 15:53:20
阅读次数:
317
题目链接:hdu 4991 Ordered Subsequence
题目大意:给定一个序列,求有多少个子序列满足长度为m,并且递增。
解题思路:dp[i][j]表示说选了以第i个数为结尾,长度为j的递增子串方案数。将每个数离散化后用树状数组维护即可。
#include
#include
#include
#include
#define lowbit(x) ((x)&(-x...
分类:
其他好文 时间:
2014-09-10 12:37:10
阅读次数:
235
题意:给定两个串,求出两个串的最长公共子序列,要求该公共子序列不包含virus串。用dp+kmp实现dp[i][j][k]表示以i结尾的字符串和以j结尾的字符串的公共子序列的长度(其中k表示该公共子序列的与virus的匹配程度)很显然,当k==strlen(virus)时,该公共子序列不是我们所求得...
分类:
其他好文 时间:
2014-09-09 20:03:59
阅读次数:
207
题意:给一串数字,问长度为m的严格上升子序列有多少个解法:首先可以离散化为10000以内,再进行dp,令dp[i][j]为以第i个元素结尾的长度为j的上升子序列的个数,则有dp[i][j] = SUM(dp[k][j-1]) (a[k] #include #include #include #inc...
分类:
其他好文 时间:
2014-09-08 02:08:16
阅读次数:
240