【HDU】5748 - Bellovin(LIS)
来源:互联网 发布:fgo网络连接异常 编辑:程序博客网 时间:2024/05/16 00:35
点击打开题目
Bellovin
Accepts: 428
Submissions: 1685
Time Limit: 6000/3000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
问题描述
Peter有一个序列a1,a2,...,an. 定义F(a1,a2,...,an)=(f1,f2,...,fn), 其中fi是以ai结尾的最长上升子序列的长度.Peter想要找到另一个序列b1,b2,...,bn使得F(a1,a2,...,an)和F(b1,b2,...,bn)相同. 对于所有可行的正整数序列, Peter想要那个字典序最小的序列.序列a1,a2,...,an比b1,b2,...,bn字典序小, 当且仅当存在一个正整数i (1≤i≤n)满足对于所有的k (1≤k<i)都有ak=bk并且ai<bi.
输入描述
输入包含多组数据, 第一行包含一个整数T表示测试数据组数. 对于每组数据:第一行包含一个整数n (1≤n≤100000)表示序列的长度. 第二行包含n个整数a1,a2,...,an (1≤ai≤109).
输出描述
对于每组数据, 输出n个整数b1,b2,...,bn (1≤bi≤109)表示那个字典序最小的序列.
输入样例
311055 4 3 2 131 3 5
输出样例
11 1 1 1 11 2 3
贴个中文题目。
其实就是求个LIS。(当时比赛的时候还不会啊,没做出来好丢人啊QAQ)
代码如下:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define CLR(a,b) memset(a,b,sizeof(a))#define INF 0x3f3f3f3f#define MAX 100000int main(){int u;int n,num[MAX+11];int dp[MAX+11];int g[MAX+11];scanf ("%d",&u);while (u--){scanf ("%d",&n);for (int i = 1 ; i <= n ; i++)scanf ("%d",&num[i]) , g[i] = INF , dp[i] = 0;for (int i = 1 ; i <= n ; i++){int pos = lower_bound(g+1 , g+n+1 , num[i]) - g;g[pos] = min(g[pos] , num[i]);dp[i] = max (pos , dp[i]);}for (int i = 1 ; i < n ; i++)printf ("%d ",dp[i]);printf ("%d\n",dp[n]);}return 0;}
0 0
- hdu 5748 Bellovin(LIS)
- HDU 5748 (Bellovin LIS)
- HDU 5748 Bellovin(LIS)
- 【HDU】5748 - Bellovin(LIS)
- HDU 5748 Bellovin(LIS)
- HDU 5748 Bellovin (LIS)
- LIS hdu 5748 (Bellovin)
- HDU-5748-Bellovin【LIS】
- 【HDU】-5748-Bellovin(LIS,变化)
- HDU-5748 Bellovin 【LIS(STL应用)】
- HDU:5748 Bellovin(LIS+打表)
- HDU 5748 Bellovin(LIS nlogn)
- HDU Problem 5748 Bellovin 【LIS】
- Bellovin【hdu 5748 dp lis】
- HDOJ 5748 Bellovin(LIS)
- HDOJ-----5748Bellovin(LIS)
- HDU 5748 BestCoder Round #84 Bellovin (LIS)(树状数组)
- hdu5748 Bellovin(LIS模板)
- linux 安装yum
- Flume整合kafka
- iOS RTMP推流和拉流第三方框架
- Java动态编译
- 源码编译安装xdebug
- 【HDU】5748 - Bellovin(LIS)
- POJ 1064 - Cable master(二分)
- hdu5795A Simple Nim/hihoCoder1173+SG博弈
- 数据结构之排序算法总结
- 使用Volley请求文本时乱码问题
- HDU 2955 Robberies(概率DP)
- 修改代码的艺术 读书笔记(一,修改代码的四种原因)
- 一款应用的UI设计是否合格,该如何判断?
- STL总结之顺序容器