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. Linux Shell 批量更换文件名或后缀名

    把下列所有.c的文件名修改为.cc rename .c .cc *.c

  2. XAF应用开发教程(八) 汉化与多国语言支持

    使用了XAF开发时,汉化是一个比较常的问题. 要实现汉化很简单: 1.在这里下载汉化资源文件.这里演示的版本是15.1.X的 2.文件下载后将:文件解压到目录    <你的项目>\BIN\ ...

  3. linux 下安装安装rz/sz命令

    一.软件安装 root 账号登陆后,依次执行以下命令: cd /tmp wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz http:/ ...

  4. MySQL数据库优化的八种方式(经典必看)

      引言: 关于数据库优化,网上有不少资料和方法,但是不少质量参差不齐,有些总结的不够到位,内容冗杂 偶尔发现了这篇文章,总结得很经典,文章流量也很大,所以拿到自己的总结文集中,积累优质文章,提升个人 ...

  5. GitHub下载的 Git Shell中出现的字符支持警告,将字体修改为新宋体即可

    ——解决办法: 将命令行字体修改为新宋体就可以了. 文章引用:http://www.cnblogs.com/veryinf/archive/2012/10/26/2740899.html

  6. [原创] WINDOWS 7 精简教程之驱动精简 可用于64和32

    追风神话 发表于 2014-9-1 11:35:56   https://www.itsk.com/forum.php?mod=viewthread&tid=334491&highli ...

  7. 谷歌 火狐 CSS兼容

    @media screen and (-webkit-min-device-pixel-ratio:0){}谷歌@-moz-document url-prefix(){}火狐

  8. page,client,offset区别

    offset:相对于当前“盒子”的距离 ,与滚动条无关 client:相对于可视区域的距离,与滚动条无关 page:相对于整个页面的距离,与滚动条有关 示例代码: <!DOCTYPE html& ...

  9. Google 黑客搜索技巧

    常用的google关键字: foo1 foo2 (也就是关联,比如搜索xx公司 xx美女) operatorfoo filetype123 类型 sitefoo.com 相对直接看网站更有意思,可以得 ...

  10. Html=>Head=>meta

    如今智能机遍布大街小巷,所以,如今的前端攻城师们要大 跨步的迈向移动互联网了,更何况Web App也应用广泛,可能原理还一样,但是一定会有新的东西出现,那就从“头”开始,看看头部那些Meta的新玩意. ...