![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划:LIS
skajre
这个作者很懒,什么都没留下…
展开
-
HDU 1950 Bridging signals 最长公共子序列(LIS)nlogn算法实现
d这个数组是用来存放最长公共子序列的,且是字典序最小的。 思路是当a数组中的数中寻找最长公共子序列时,假设dp[i]这个数组放的是以i结尾的最长公共子序列长度,那么假设dp[x]=dp[y]且x 代码如下: #include #include #include #include using namespace std; const int maxn=40010; int d[maxn]; i原创 2016-07-07 14:02:36 · 204 阅读 · 0 评论 -
UVA 10534 Wavio Sequence(LIS O(nlogn))
p数组需要初始化。#include #include #include #include using namespace std; const int maxn=10000+10; int s[maxn],p[maxn],f1[maxn],f2[maxn]; int main() { int n; while(scanf("%d",&n)!=EOF) { f原创 2016-10-11 19:18:54 · 255 阅读 · 0 评论 -
LIS O(nlogn) (lower_bound实现)
// // main.cpp // Richard // // Created by 邵金杰 on 16/10/2. // Mail:1016427040@qq.com or jasonshaosjj@gmail.com // Copyright © 2016年 邵金杰. All rights reserved. // #include #include #include #incl原创 2016-10-02 19:05:50 · 585 阅读 · 0 评论 -
UVA 10635 Prince and Princess(LCS转LIS)
如果LCS的元素两两都不相同,可以转成LIS的nlogn做法。 // // main.cpp // Richard // // Created by 邵金杰 on 16/10/2. // Mail:1016427040@qq.com or jasonshaosjj@gmail.com // Copyright © 2016年 邵金杰. All rights reserved. //原创 2016-10-02 23:43:37 · 318 阅读 · 0 评论