打印严格上升子序列;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<time.h>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
#define mclr(x,a) memset((x),a,sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 9999973;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-5
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii; inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/
int n;
int a[maxn];
int pos[maxn];
int dp[maxn];
int lst[maxn]; int main()
{
// ios::sync_with_stdio(0);
int x;// n = rd();
n = 0;
while (cin >> x) {
n++; a[n] = x;
}
int len = 1, po = 1;
dp[1] = a[1]; pos[1] = 1;
for (int i = 2; i <= n; i++) {
if (a[i] > dp[len]) {
dp[++len] = a[i]; pos[++po] = len;
}
else {
int ct = lower_bound(dp + 1, dp + len + 1, a[i]) - dp;
dp[ct] = a[i]; pos[++po] = ct;
}
}
cout << len << endl;
puts("-");
int tmp = len;
for (int i = n; i >= 1; i--) {
if (pos[i] == tmp)lst[tmp--] = a[i];
if (tmp < 1)break;
}
for (int i = 1; i <= len; i++)printf("%d\n", lst[i]);
return 0;
}

What Goes Up UVA - 481 LIS+打印路径 【模板】的更多相关文章

  1. Uva 10131 Is Bigger Smarter? (LIS,打印路径)

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=1072">链接:UVa 10131 题意: ...

  2. Uva 10054 欧拉回路 打印路径

    看是否有欧拉回路 有的话打印路径 欧拉回路存在的条件: 如果是有向图的话 1.底图必须是连通图 2.最多有两个点的入度不等于出度 且一个点的入度=出度+1 一个点的入度=出度-1 如果是无向图的话 1 ...

  3. Floyd 算法 打印路径模板

    #include <iostream> #include <cstdlib> #include <cstdio> #include <algorithm> ...

  4. UVa 103 - Stacking Boxes (LIS,打印路径)

    链接:UVa 103 题意:给n维图形,它们的边长是{d1,d2,d3...dn},  对于两个n维图形,求满足当中一个的全部边长 依照随意顺序都一一相应小于还有一个的边长,这种最长序列的个数,而且打 ...

  5. UVA 10054 The Necklace(欧拉回路,打印路径)

    题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  6. HDU-1160.FatMouse'sSpeed.(LIS变形 + 路径打印)

    本题大意:给定一定数量的数对,每个数保存着一只老鼠的质量和速度,让你求出一个最长序列,这个序列按照质量严格递增,速度严格递减排列,让你输出这个序列的最长长度,并且输出组成这个最长长度的序列的对应的老鼠 ...

  7. UVA 1626 区间dp、打印路径

    uva 紫书例题,这个区间dp最容易错的应该是(S)这种匹配情况,如果不是题目中给了提示我就忽略了,只想着左右分割忘记了这种特殊的例子. dp[i][j]=MIN{dp[i+1][j-1] | if( ...

  8. uva 116 Unidirectional TSP【号码塔+打印路径】

    主题: uva 116 Unidirectional TSP 意甲冠军:给定一个矩阵,当前格儿童值三个方向回格最小值和当前的和,就第一列的最小值并打印路径(同样则去字典序最小的). 分析:刚開始想错了 ...

  9. UVA 624 (0 1背包 + 打印路径)

    #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #i ...

随机推荐

  1. 分析比较多表查询中的IN与JOIN

    IN 是子查询的关键字,JOIN 是连接的关键字,项目开发中经常会使用到多表查询,而子查询与连接正是实现多表查询的重要途径.那两者是怎么运行的?IN与JOIN哪个更好?下面就来分析与比较. 现在有te ...

  2. 病症:arm启动后应用程序界面显示…

    病症:病症:arm启动后应用程序界面显示不正常(左面有部分未能正常显示)也就是左面少一块区域,右面多一部, 原因:lcd显示驱动中场扫描的问题 平台:s3c2416.linux2.6.800*480l ...

  3. BigDecimal与double

    前几天,系统处理double类型的加减法,出现问题. 请看题: 示例1 问, 结果是多少? 0.01? No! 结果是0.009999999999999998! 为什么会这样呢? 因为float和do ...

  4. oracle数据库导入导出数据

    导出命令 exp username/password@192.168.x.xx/orcl file='D:\20170126.dmp' log='D:\20170126.log' 导入命令 imp u ...

  5. UnityGUI Keynote

    [UnityGUI Keynote] 1.GUI.Label控件可以用来显示texture: 更通用的作法是用label来显式texture. 2.GUI.Button可以显示texture.stri ...

  6. 【原创】4. MYSQL++ 之 SQLTypeAdapter类型、SQLQueryParms类型 与 SQLBuffer

    1. mysqlpp::SQLBuffer 该类型其实就是SQLTypeAdapter传入的各种类型(int, string, double, long, String, …) 的包装,包装的结果就是 ...

  7. Jquery异步

    一.Jquery向aspx页面请求数据$("#Button1").bind("click", function () { $.ajax({ type: &quo ...

  8. Mock Server实践

    转载自 https://tech.meituan.com/mock-server-in-action.html 背景 在美团服务端测试中,被测服务通常依赖于一系列的外部模块,被测服务与外部模块间通过R ...

  9. CSS变量教程

    今年三月,微软宣布 Edge 浏览器将支持 CSS 变量. 这个重要的 CSS 新功能,所有主要浏览器已经都支持了.本文全面介绍如何使用它,你会发现原生 CSS 从此变得异常强大. 一.变量的声明 声 ...

  10. 11.BETWEEN 操作符

    BETWEEN 操作符在 WHERE 子句中使用,作用是选取介于两个值之间的数据范围. BETWEEN 操作符 操作符 BETWEEN ... AND 会选取介于两个值之间的数据范围.这些值可以是数值 ...