题目大意:不知,根据样例猜测为最长上升子序列(竟然还对了)

题解:$O(n log_2 n)$,求二维偏序,(q为存答案的序列,a存原序列,len为答案)

for(int i = 1; i <= n; i++) {
    if(a[i] > q[len]) {q[++len]=a[i];continue;}
    *upper_bound(q, q + len, a[i]) = a[i];
}

卡点:

C++ Code:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int T, n ,a;
int f[40010], cnt;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
memset(f, 0x3f, sizeof f);
for (int i = 0 ; i < n; i++) {
scanf("%d", &a);
*lower_bound(f, f + n, a) = a;
}
printf("%d\n",lower_bound(f, f + n, 0x3f3f3f3f) - f);
}
return 0;
}

  

[POJ1631]Bridging signals的更多相关文章

  1. [POJ1631]Bridging signals (DP,二分优化)

    题目链接:http://poj.org/problem?id=1631 就是求一个LIS,但是范围太大(n≤40000),无法用常规O(n²)的朴素DP算法,这时需要优化. 新加一个数组s[]来维护长 ...

  2. POJ 1631 Bridging signals

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9441   Accepted: 5166 ...

  3. hdu----(1950)Bridging signals(最长递增子序列 (LIS) )

    Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. poj 1631 Bridging signals (二分||DP||最长递增子序列)

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9234   Accepted: 5037 ...

  5. OpenJudge/Poj 1631 Bridging signals

    1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/1631 2.题目: Bridging sign ...

  6. POJ 1631 Bridging signals(LIS O(nlogn)算法)

    Bridging signals Description 'Oh no, they've done it again', cries the chief designer at the Waferla ...

  7. hdoj 1950 Bridging signals【二分求最大上升子序列长度】【LIS】

    Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. Bridging signals(二分 二分+stl dp)

    欢迎参加——每周六晚的BestCoder(有米!) Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 6 ...

  9. POJ 1631 Bridging signals(LIS 二分法 高速方法)

    Language: Default Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1076 ...

随机推荐

  1. html样式不兼容 详解(转)

    网站对火狐不兼容的原因以及解决的方法 1.DOCTYPE 影响 CSS 处理 2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行 3. ...

  2. Java小功能大杂烩

    生成UUID: import java.util.UUID; public class ProductUUID { // 随机返回前十位的UUID public static String getUU ...

  3. Java : java基础(3) IO流

    流按操作类型分为两种,字节流,字符流,按流向分为输入流,输出流,输入流的抽象父类InputStream,输出流抽象父类OutputStream,字符流的抽象父类是Reader和Writer 一般用字节 ...

  4. C#截取两个字符串间的字符串问题

    string s = "我爱北京天安门和长城"; string s1 = "北京"; string s2 = "和"; int i = s. ...

  5. ODBC error in PHP: “No tuples available at this result index”

    ODBC error in PHP: “No tuples available at this result index” 在执行存储过程的时候发生如题的错误,在stackoverflow上找到了相同 ...

  6. python 排列组合

    笛卡尔积(product): 假设集合A={a, b},集合B={0, 1, 2},则两个集合的笛卡尔积为{(a, 0), (a, 1), (a, 2), (b, 0), (b, 1), (b, 2) ...

  7. uva 509 RAID!(磁盘数据)

    来自 https://blog.csdn.net/su_cicada/article/details/80085318 习题4-7 RAID技术(RAID!, ACM/ICPC World Final ...

  8. Linux mysql启动与关闭

    service mysql stop service mysqld start

  9. 洛谷(P1006 传纸条)

    题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个mm行nn列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸运 ...

  10. 5 多线程 模拟qq聊天

    1.多线程思路 使用多线程完成一个全双工的QQ聊天程序 2.版本1:程序小框架 #1.收数据,然后打印 def recvData(): pass #2.检测键盘,发数据 def sendData(): ...