link:http://codeforces.com/problemset/problem/4/D

 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <cmath>
 #include <cctype>
 #include <algorithm>
 #include <queue>
 #include <deque>
 #include <queue>
 #include <list>
 #include <map>
 #include <set>
 #include <vector>
 #include <utility>
 #include <functional>
 #include <fstream>
 #include <iomanip>
 #include <sstream>
 #include <numeric>
 #include <cassert>
 #include <ctime>
 #include <iterator>
 const int INF = 0x3f3f3f3f;
 ][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
 using namespace std;
 ],path[],End;
 bool flag;
 typedef struct node
 {
     int W,H,In;
     bool operator < (const node &other) const
     {
         if(W!=other.W) return W<other.W;
         else return H<other.H;
     }
 }node;
 node ma[];
 bool judge(node a,node b)
 {
     if(a.W<b.W&&a.H<b.H) return true; else return false;
 }
 void print_ans(int i)
 {
     ) return;
     print_ans(path[i]);
     printf();
 }
 int main(void)
 {
     #ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin );
     #endif // ONLINE_JUDGE

     while(~scanf("%d%d%d",&n,&w,&h))
     {
         flag=;
         ;i<n;++i)
         {
             int a,b;
             scanf("%d%d",&a,&b);
             if(a<=w||b<=h) continue;
             flag=true; ma[cnt].W=a; ma[cnt].H=b; ma[cnt].In=i;
             cnt++;
         }
         if(!flag)
         {
             printf("0\n"); continue;
         }
         sort(ma,ma+cnt);
         ans=;
         memset(d,,sizeof(d));
         memset(path,-,sizeof(path));
         End=;
         ;i<cnt;++i) d[i]=;
         ;i<cnt;++i)
         {
             ;
             ;j<i;++j)
             {
                 if(judge(ma[j],ma[i]))
                 {
                     if(tmp<d[j])
                     {
                         tmp=d[j]; path[i]=j;
                     }
                 }
             }
             d[i]=tmp+;
             if(ans<d[i])
             {
                 ans=d[i]; End=i;
             }
         }
         printf("%d\n",ans);
         print_ans(End);
         printf("\n");
 //        printf("%d\n",ma[End-1].In+1);
     }

     ;
 }

最长上升子序列还写这么挫哦

这两天沉迷于kpw……囧

codeforces mysterious present 最长上升子序列+倒序打印路径的更多相关文章

  1. 最长公共子序列Lcs(打印路径)

    给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的).   比如两个串为:   abcicba abdkscab   ab是两个串的子序列,abc也是,abca也是,其中abca是这 ...

  2. HDU - 1160 最长上升子序列以及记录路径

    题意:第一列,给出老鼠的重量,第二列,给出老鼠的速度,要证明老鼠的重量越大,速度越小,给出最多老鼠的数量,并说明第几只. 思路:先将老鼠按照重量从大到小排序,然后速度是从小到大,求最长上升子序列,学习 ...

  3. 51nod_1006 最长公共子序列,输出路径【DP】

    题意: 给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的). 比如两个串为: abcicba abdkscab ab是两个串的子序列,abc也是,abca也是,其中abca是这两个 ...

  4. zoj 3088 Easter Holidays(最长路+最短路+打印路径)

    Scandinavians often make vacation during the Easter holidays in the largest ski resort Are. Are prov ...

  5. Codeforces 3A-Shortest path of the king(BFS打印路径)

    A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input s ...

  6. POJ 2250(LCS最长公共子序列)

    compromise Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Descri ...

  7. 动态规划——最长公共子序列LCS及模板

    摘自 https://www.cnblogs.com/hapjin/p/5572483.html 这位大佬写的对理解DP也很有帮助,我就直接摘抄过来了,代码部分来自我做过的题 一,问题描述 给定两个字 ...

  8. Codeforces Beta Round #4 (Div. 2 Only) D. Mysterious Present 记忆化搜索

    D. Mysterious Present 题目连接: http://www.codeforces.com/contest/4/problem/D Description Peter decided ...

  9. Codeforces 4D Mysterious Present

    http://codeforces.com/contest/4/problem/D 题目大意: 给出n个信封,这n个信封有长和宽,给出卡片的尺寸,求取能够装入卡片的最长的序列,序列满足后一个的长和宽一 ...

随机推荐

  1. LTE Module User Documentation(翻译8)——核心网(EPC)

    LTE用户文档 (如有不当的地方,欢迎指正!) 14 Evolved Packet Core (EPC)   我们现在讲解如何编写一个仿真程序——除了 LTE 无线接入网外,还允许仿真 EPC. EP ...

  2. phonegap开发经验谈之一命令行建立项目和准备工作

    一安装与配置 安装命令行配置,这个可以参见网上的.3.0的最好用命令行配置. 大家在安装android sdk的时候,会发现里面自带了一个eclipse,并且继承了adt,直接用这个就好了.当然你已经 ...

  3. 当一个类、一个实例域、方法被定义为private、public 时意味着什么

    1.设计private public的原因 2.当一个类.一个实例域.方法被定义为private.public 时意味着什么

  4. CoreText原理及基本使用方法

    关于富文本的排版也是现在的一个技术点,以下是近日关于CoreText的学习记录以及个人理解,希望能对正在学习CoreText的朋友起到帮助. 1.框架坐标系 首先让我们先来看看CoreText坐标系和 ...

  5. PHP 小方法之 随机生成几位字符串

    if(! function_exists ('get_rand_string') ) { function get_rand_string($len=6,$format='ALL') { switch ...

  6. android,NDK android.mk相关

    1.c++ try...catch的支持 需要在Android.mk 中添加 LOCAL_CPPFLAGS += -fexceptions,或者在Application.mk中添加APP_CPPFLA ...

  7. OPENGL学习之路(0)--安装

    此次实验目的: 安装并且配置环境. 1 下载 https://www.opengl.org/ https://www.opengl.org/wiki/Getting_Started#Downloadi ...

  8. PE文件学习系列一为什么是PE

    合肥程序员群:49313181.    合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入)Q  Q:408365330     E-Mail:egojit@qq.com PE概述: ...

  9. iOS开发拓展篇—静态库

    iOS开发拓展篇—静态库 一.简单介绍 1.什么是库? 库是程序代码的集合,是共享程序代码的一种方式 2.库的分类 根据源代码的公开情况,库可以分为2种类型 (1)开源库 公开源代码,能看到具体实现 ...

  10. 没有纳入spring管理的类如何注入spring管理的对象

    spring 如何在普通类中调用注入的对象? spring 在Thread中注入@Resource失败,总为null~解决 springmvc 注入总是空指针异常? 以上的几个问题就是我在项目中遇到的 ...