poj 1631 LIS】的更多相关文章

题目链接:http://poj.org/problem?id=1631 #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> using namespace std; ; ; const int INF = 0x3f3f…
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 2 3 4 5.... 右边的数字 第一个输入的和1连 第2个输入的和2连 右边再按从小到大排序 要求连线不能交叉 问最多能有多少条不交叉的线 假如右边有5个1 那么答案会是5 所以是最大非降子序列 Sample Input4 //T6 //n426315 Sample Output 3 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm&…
题意:给你一个长为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且该序列末尾值&…
题意:题目很难懂,题意很简单,求最长递增子序列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&…
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…
方法一: 二分 我们可以知道 最长上升子序列的 最后一个数的值是随序列的长度而递增的 (呃呃呃 意会意会) 然后我们就可以二分找值了(并更新) //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,cases,a[100050],f[100050],vis[100050]; int search(int x){ int l=0…
题意:左右各n个端口,已知n组线路,要求切除最少的线路,使剩下的线路各不相交,按照左端口递增的顺序输入. 分析: 1.设左端口为l,右端口为r,因为左端口递增输入,l[i] < l[j](i < j),因此若要不相交,r[i] < r[j],由此可以得出,只要求出对应的右端口序列的最长上升子序列的长度即可. 2.最长上升子序列: dp[i]---长度为i+1的上升子序列中末尾元素的最小值(若不存在,则为INT_INF). 如果子序列长度相同,那么最末位元素较小的在之后会更加有优势. #p…
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…