题意:

序列arr[i--n];输出以a[i]为结尾的最长上升子序列。1<=n<=100000;

思路:

O(n*log(n)),求最长上升子序列。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100000+100;
int arr[maxn];
int main ()
{
int T;scanf("%d",&T);
while(T--)
{
int n,k=0;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int t;
scanf("%d",&t);
int pos=int(lower_bound(arr,arr+k,t)-arr);
printf("%d",pos+1);
if(i<n)
printf(" ");
if(pos==k)
k++;
arr[pos]=t;
}
printf("\n");
}
return 0;
}

div.2/Bellovin<最长上升子序列>的更多相关文章

  1. hdu 5748 Bellovin【最长上升子序列】

    题目链接:https://vjudge.net/contest/148584#problem/A 题目大意: 解题思路:题目要求为:输出与已知序列的每一个元素的f(i)(f(i)的定义如题)相同的字典 ...

  2. Codeforces Round #345 Div.1 D.Zip-line 动态最长上升子序列

    题意概述: 给出一个长度为N的序列和M组询问,问假设把某个位置的值改成另一个给出的值之后,序列的最长上升子序列的长度. N,M<=400000. 分析: 考虑某个位置的值改动后这个位置和最长上升 ...

  3. codeforces #345 (Div. 1) D. Zip-line (线段树+最长上升子序列)

    Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long a ...

  4. HDU 5748 最长上升子序列的长度nlogn(固定尾部)

    Bellovin Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  5. 用python实现最长公共子序列算法(找到所有最长公共子串)

    软件安全的一个小实验,正好复习一下LCS的写法. 实现LCS的算法和算法导论上的方式基本一致,都是先建好两个表,一个存储在(i,j)处当前最长公共子序列长度,另一个存储在(i,j)处的回溯方向. 相对 ...

  6. 动态规划之最长公共子序列(LCS)

    转自:http://segmentfault.com/blog/exploring/ LCS 问题描述 定义: 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...

  7. [Data Structure] LCSs——最长公共子序列和最长公共子串

    1. 什么是 LCSs? 什么是 LCSs? 好多博友看到这几个字母可能比较困惑,因为这是我自己对两个常见问题的统称,它们分别为最长公共子序列问题(Longest-Common-Subsequence ...

  8. 动态规划求最长公共子序列(Longest Common Subsequence, LCS)

    1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...

  9. LintCode 77: 最长公共子序列

    public class Solution { /** * @param A, B: Two string. * @return: the length of the longest common s ...

随机推荐

  1. 如何判断网页中引入jquery

    直接上代码,不信自己测. <html xmlns="http://www.w3.org/1999/xhtml"><meta http-equiv="Co ...

  2. 越狱开发-创建真正的后台程序(Daemon Process)

    在网上搜索了一下如何在IOS上面实现Daemon Process,只有chrisalvares的博客中有过详细的描述,但是其博客中描述的较为复杂, 参考stackoverflow中的一个问答: htt ...

  3. HDU 2955 Robberies(01背包)

    Robberies Problem Description The aspiring Roy the Robber has seen a lot of American movies, and kno ...

  4. TortoiseGit - Gitblit使用简介

    1. 增加Repository http://192.168.242.128:10101 用admin admin登陆后,点击"版本库"--> 创建版本库 填写好 " ...

  5. [ An Ac a Day ^_^ ] CodeForces 601A The Two Routes 最短路

    14号就ccpc全国赛的全国赛了 而且也快东北赛的选拔赛了 现在队伍实力实在不行 参加了也是边缘化的队伍 虽然有新生保护的设置 但实话说 机会还是不大 所以不如趁现在开始好好努力 明年也许还有机会 A ...

  6. 判断手机电脑微信 js

    if ((navigator.userAgent.match(/(MicroMessenger)/i))) { //微信浏览器 //location.href=""; } else ...

  7. SharePoint 2013 工作流设计之Designer 使用“可视化视图

    转载自:http://www.cnblogs.com/jianyus/p/3406309.html SharePoint 2013增强了工作流功能,而Designer里面也添加了可视化设计视图,也就是 ...

  8. 34.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,要求printCapitalLetter()方法 实现输出大写英文字母表的功能,

    //接口InterfaceA package jieKou; public interface IInterfaceA { void printCapitalLetter(); } //接口Inter ...

  9. Ant 删除目录 vs 清空目录

    Apache Ant 可以用下面的命令来删除目录 <delete dir="${lucene.dir}"/> 但是这会删除整个目录,而我现在只想清空目录内的所有文件和子 ...

  10. JPA基本注解介绍

    一.@Entity •@Entity 标注用于实体类声明语句之前, 指出该Java 类为实体类,将映射到指定的数据库表. 如声明一个实体类 Customer,它将映射到数据库中的 customer 表 ...