最长递增子序列?Why?朦朦胧胧的感觉也许是这样的。。大神说要用Dilworth定理来证明无爱了,这个定理先放一放吧 1 //#define LOCAL 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 ...
分类:
其他好文 时间:
2014-07-22 22:46:58
阅读次数:
238
Wavio Sequence
Wavio is a sequence of integers. It has some interesting properties.
· Wavio is of odd length i.e. L = 2*n + 1.
· The first (n+1) integers of Wavio sequence makes a strictly i...
分类:
其他好文 时间:
2014-07-22 14:36:14
阅读次数:
248
思路:1、开辟数组L,L[i]记录的为a[0]~a[i]的最长递增子序列长度2、开辟数组maxV,maxV[i]记录的为长度为i的各递增子序列的最后一个元素的最小值,譬如有子序列1,2,4 1,2,5则maxV[3] = 43、使用maxLen记录当前的最长递增子序列长度4、转移方程:L[i+1] ...
分类:
其他好文 时间:
2014-07-22 00:17:35
阅读次数:
189
在第三节中,我们将讨论序列化问题中的动态规划解法。这部分多半分为单序列和双序列等问题
例一:最长上升子序列。
最长上升子序列问题,有一个正整数数列,长度n在1000之内,元素a[i]在10^5之内,求最长递增子序列的长度。
分析一:发现问题的可分性质
如果我们采用穷举法,将有2^n的时间复杂度;这里面有很多是重复的4、3、***类型的子序列,以4开头的递增子序列的长度都是1....
分类:
其他好文 时间:
2014-07-21 15:34:06
阅读次数:
207
一般情况:
#include
#include
#include
using namespace std;
int a[1005],dp[1005],n;
int LIS()
{
int i,j,ans,m;
dp[1] = 1;
ans = 1;
for(i = 2;i<=n;i++)
{
m = 0;
for(...
分类:
其他好文 时间:
2014-07-21 11:23:15
阅读次数:
185
题意:求最长递增子序列
AC代码:#include
#include
#include
using namespace std;
int dp[1010],a[1010];
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;...
分类:
其他好文 时间:
2014-07-20 10:28:31
阅读次数:
235
Longest Ordered Subsequence
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 32192
Accepted: 14093
Description
A numeric sequence of ai is ordered if a1 a...
分类:
其他好文 时间:
2014-07-19 11:47:53
阅读次数:
169
题:求一个一维数组arr[i]中的最长递增子序列的长度,如在序列1,-1,2,-3,4,-5,6,-7中,最长递增子序列长度为4,可以是1,2,4,6,也可以是-1,2,4,6。 从后向前分析,很容易想到,第i个元素之前的最长递增子序列的长度要么是1(单独成一个序列), 要么就是第i-1个元素之前的...
分类:
其他好文 时间:
2014-07-16 21:06:57
阅读次数:
160
(1)最长递增子序列问题有两种方法:(1)动态规划方法(2)类似二分查找的方法O(nlogn)动态规划方法: 以i结尾的序列的最长递增子序列和其[0, i - 1]“前缀”的最长递增子序列有关,设LIS[i]保存以i结尾的最长递增子序列的长度:若i = 0,则LIS[i] = 1; 若i > 0,....
分类:
其他好文 时间:
2014-07-14 22:05:35
阅读次数:
474
求数组中最长递增子序列的长度
个人信息:就读于燕大本科软件工程专业 目前大三;
本人博客:google搜索“cqs_2012”即可;
个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献;
编程语言:C++ ;
编程坏境:Windows 7 专业版 x64;
编程工具:vs2008;
制图工具:office 2010 powerpoi...
分类:
其他好文 时间:
2014-06-15 15:53:26
阅读次数:
159