题意:给你一个长为n(n<=40000)的整数序列, 要你求出该序列的最长上升子序列LIS. 思路:要求(nlogn)解法 令g[i]==x表示当前遍历到的长度为i的所有最长上升子序列中的最小序列末尾值为x.(如果到目前为止, 根本不存在长i的上升序列, 那么x==INF无穷大) 假设当前遍历到了第j个值即a[j], 那么先找到g[n]数组的值a[j]的下确界k(即第一个>=a[j]值的g[k]的k值). 那么此时表明存在长度为k-1的最长上升子序列且该序列末尾的位置<j且该序列末尾值&…
Language: Default Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 10762   Accepted: 5899 Description 'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers…
Bridging signals Description 'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of two functional blo…
1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/1631 2.题目: Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9882   Accepted: 5409 Description 'Oh no, they've done it again', cries the chief des…
Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9441   Accepted: 5166 Description 'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up co…
Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9234   Accepted: 5037 Description 'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up co…
题意:题目很难懂,题意很简单,求最长递增子序列LIS. 分析:本题的最大数据40000,多个case.用基础的O(N^2)动态规划求解是超时,采用O(n*log2n)的二分查找加速的改进型DP后AC了. 在基础的动态规划解法中,由于动态规划的无后效性(对于每个阶段来说,它以前的各阶段状态无法直接影响它未来的决策,只能间接地通过当前状态来影响),当我们考察第i+1个元素的时候,我们是不考虑前面i个元素的分布情况的.当我们考虑前面的情况时会发现,对于前面i个元素的任意一个递增子序列,如果这个子序列的…
把左边固定,看右边,要求线不相交,编号满足单调性,其实是LIS的等价表述. (如果编号是乱的也可以把它有序化就像Uva 10635 Prince and Princess那样 O(nlogn) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<queue> #include<vector> #include<stack&…
题意:左右各n个端口,已知n组线路,要求切除最少的线路,使剩下的线路各不相交,按照左端口递增的顺序输入. 分析: 1.设左端口为l,右端口为r,因为左端口递增输入,l[i] < l[j](i < j),因此若要不相交,r[i] < r[j],由此可以得出,只要求出对应的右端口序列的最长上升子序列的长度即可. 2.最长上升子序列: dp[i]---长度为i+1的上升子序列中末尾元素的最小值(若不存在,则为INT_INF). 如果子序列长度相同,那么最末位元素较小的在之后会更加有优势. #p…
两个都是最长上升子序列,所以就放一起了 1631 因为长度为40000,所以要用O(nlogn)的算法,其实就是另用一个数组c来存储当前最长子序列每一位的最小值,然后二分查找当前值在其中的位置:如果当前点不能作为当前最长子序列的最大值,则更新找到值为两者间的较小值. 2533 就是一个裸的最长上升子序列...这里就不多说了,直接dp就好... 1611: #include <iostream> #include <cstring> #include <cstdio> #…