题意:找最长公共子序列(不要求连续)
分析:二维dp肯定的,不过我自己用的四层循环,超时;正解是画矩阵,找规律。以后要多注意这种思想
WA了很多遍,原因:1.对数组边界的处理;2.while(1)超时,改成while(cin>>a>>b)就过了
代码:
#include
#include
#define max(a,b) a>b?a:b
using namespace s...
分类:
其他好文 时间:
2015-06-07 15:50:06
阅读次数:
110
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from th...
分类:
其他好文 时间:
2015-06-07 12:28:40
阅读次数:
78
升级版的最大子列和问题没什么好说的#include using namespace std;int main(){ int n; cin >> n; int *a = (int*)malloc(n*sizeof(int)); for (int i = 0; i > a[i];...
分类:
其他好文 时间:
2015-06-04 22:38:40
阅读次数:
191
题目:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the o...
分类:
其他好文 时间:
2015-06-04 21:03:00
阅读次数:
130
题目传送门 1 /* 2 题意:求连续子序列的和不小于s的长度的最小值 3 尺取法:对数组保存一组下标(起点,终点),使用两端点得到答案 4 1. 记录前i项的总和,求[i, p)长度的最小值,用二分找到sum[p] - s[i] >= s的p 5 2...
分类:
其他好文 时间:
2015-06-03 21:26:58
阅读次数:
161
这个好多算法书上都有,不仅限于《算法导论》
时间限制:3000 ms | 内存限制:65535 KB
难度:3
描述
咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。
tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ...
分类:
其他好文 时间:
2015-06-03 15:54:35
阅读次数:
124
题目连接http://poj.org/problem?id=3061SubsequenceDescriptionA sequence of N positive integers (10 2 #include 3 #include 4 #include 5 #include 6 using std....
分类:
其他好文 时间:
2015-06-01 22:07:52
阅读次数:
95
Subsequence
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 9587
Accepted: 3855
Description
A sequence of N positive integers (10 < N < 100 000), each of the...
分类:
其他好文 时间:
2015-05-28 09:43:33
阅读次数:
143
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the...
分类:
其他好文 时间:
2015-05-26 17:54:40
阅读次数:
123
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of ...
分类:
其他好文 时间:
2015-05-26 12:19:11
阅读次数:
144