杭电 5748 Bellovin
Description











and he define a function on the sequence -- 




























, where 
is the length of the longest increasing subsequence ending with 
.
Peter would like to find another sequence 










in such a manner that 













equals to 













. Among all the possible sequences consisting of only positive integers, Peter wants the lexicographically smallest one.
The sequence 










is lexicographically smaller than sequence 










, if there is such number
from
to
, that 



for 



and 



.
Input
, indicating the number of test cases. For each test case:
The first contains an integer











-- the length of the sequence. The second line contains
integers 



















.
Output
integers 



















denoting the lexicographically smallest sequence. Sample Input
3
1
10
5
5 4 3 2 1
3
1 3 5
Sample Output
1
1 1 1 1 1
1 2 3 英语题目很难度,但是题意很简单,给你一个整数序列,输出以每个数结尾的最长上升子序列的长度。
#include<cstdio>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int dp[];
int a[];
int b[];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,i,j;
scanf("%d",&n);
for(i = ; i <= n ; i++)
{
scanf("%d",&a[i]);
dp[i]=;
b[i]=INF;
}
for(i = ; i <= n ; i++)
{
int k=lower_bound(b+,b+n+,a[i])-b; //函数返回值为大于a[i]的第一个值的位置,比如序列1 1 4 5,a[i]为2,返回值为3
dp[i]=k; //与二分法类似,将数放入新数组
b[k]=a[i];
}
for(i = ; i < n ; i++)
printf("%d ",dp[i]);
printf("%d\n",dp[n]);
}
}
杭电 5748 Bellovin的更多相关文章
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
- 杭电acm 1002 大数模板(一)
从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...
- 杭电OJ——1198 Farm Irrigation (并查集)
畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”
按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...
- C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~
暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...
- 杭电ACM2076--夹角有多大(题目已修改,注意读题)
杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...
- 杭电ACM2092--整数解
杭电ACM2092--整数解 分析 http://acm.hdu.edu.cn/showproblem.php?pid=2092 一个YES,一个Yes.试了10几次..我也是无语了..哪里都不 ...
- 杭电2034——人见人爱A-B
#include <stdio.h> #include <algorithm> using namespace std; int main () { int a[110],b[ ...
随机推荐
- [JSOI2015]染色游戏
Description 棋盘是一个n×m的矩形,分成n行m列共n*m个小方格. 现在萌萌和南南有C种不同颜色的颜料,他们希望把棋盘用这些颜料染色,并满足以下规定: 1.棋盘的每一个小方格既可以染色(染 ...
- HDU6301(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6301 队友AC的,没怎么看 #include<iostream> #incl ...
- Java EE学习笔记(二)
Spring中的Bean 1.Bean的配置: a).Bean的本质就是Java中的类,而Spring中的Bean其实就是对实体类的引用,来生产Java类对象,从而实现生产和管理Bean . b).S ...
- 手动释放Linux内存
查看内存: [root@iZ9dp52tlpqyihuisujjswZ bin]# free -h total used free shared buff/cache available Mem: 3 ...
- 12.Maps
1 Maps 1.1 Map声明和访问 maps中的元素是key-value对儿,key与value之间使用冒号(:)分割.创建一个空value的map,使用[:].默认情况下,map的 ...
- JavaScript 获取浏览器版本
//获取IE版本function GetIEVersions(){ var iejson={ isIE:false,safariVersion:0 }; var ua = navigator.user ...
- IE和火狐下的iframe刷新
前面使用了前端上传插件plupload,在谷歌浏览器中运行完全没问题,但是在IE和火狐下就出现当文档加载完成之后,该文件上传的iframe插件的上传按钮点击无效,当对上传的文件进行一次删除之后,按钮就 ...
- Ubuntu安装新英伟达驱动出现问题解决方法
ERROR: The Nouveau kernel driver is currently in use by your system. This driver is incompatible wit ...
- iOS 锁的常用方法
锁的用法在iOS中有几种方法来解决多线程访问同一个内存地址的互斥同步问题: 方法一,@synchronized(id anObject),(最简单的方法)会自动对参数对象加锁,保证临界区内的代码线程安 ...
- ipsec配置strongswan.conf和ipsec.conf
配置strongswan.conf vi /usr/local/etc/strongswan.conf # strongswan.conf - strongSwan configuration fil ...