POJ 1631 Bridging signals(LIS的等价表述)
2015-10-17 12:58
357 查看
把左边固定,看右边,要求线不相交,编号满足单调性,其实是LIS的等价表述。
(如果编号是乱的也可以把它有序化就像Uva 10635 Prince and Princess那样
O(nlogn)
(如果编号是乱的也可以把它有序化就像Uva 10635 Prince and Princess那样
O(nlogn)
#include<cstdio> #include<iostream> #include<string> #include<cstring> #include<queue> #include<vector> #include<stack> #include<vector> #include<map> #include<set> #include<algorithm> //#include<bits/stdc++.h> using namespace std; const int maxn = 4e4+5; int g[maxn]; //#define LOCAL int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif int T; cin>>T; while(T--){ int n, ans = 0; scanf("%d",&n); for(int i = 0,c = 1; i < n; i++){ int x, k; scanf("%d",&x); k = lower_bound(g+1,g+c,x)-g; ans = max(ans,k); g[k] = x; if(k==c) c++; //不用把辅助数组g初始化,只要维护一个下标即可 } printf("%d\n",ans); } return 0; }
相关文章推荐
- Tricks of Android's GUI
- 不是hihocoder 1111 只是算哈弗曼编码长度
- 黑马程序员--NSNumber NSValue
- Code Forces 585 B. Phillip and Trains(BFS)
- 关于SimpleDateFormat的使用方法
- mysqldump导出数据库 (dos环境下)
- Android自定义drawable
- 自己做过分页功能吗?我们一起打造自己的分页控件
- 【UIKit-33-1】UIDatePicker - 时间选择器
- 黑马程序员--NSFileManage
- 委托模式
- 图像宽度所占字节必须是4的倍数详解
- 由数学归纳法想到的
- Spring3中用注解直接注入properties中的值
- android两种定时器实现
- 1256 Anagram
- ios UIWebView 加载网页、文件、 html
- Android学习第四天之表格布局TableLayout
- Unity 5.1+ Assertion Library (断言库)
- Machine Learning--Andrew Ng--week4