https://vjudge.net/contest/68966#problem/J

【Accepted】

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm> using namespace std;
const int maxn=1e3+;
struct node
{
int w;
int s;
int id;
}a[maxn];
int pre[maxn];
int dp[maxn];
bool cmp(node x,node y)
{
return x.w<y.w;
} void Print(int pos)
{
if(pos==-) return;
Print(pre[pos]);
printf("%d\n",a[pos].id);
}
int main()
{
int cnt=;
while(scanf("%d%d",&a[cnt].w,&a[cnt].s)!=EOF)
{
a[cnt].id=cnt+;
cnt++;
}
sort(a,a+cnt,cmp);
memset(pre,-,sizeof(pre));
fill(dp,dp+cnt,);
for(int i=;i<cnt;i++)
{
for(int j=;j<i;j++)
{
if(a[j].w<a[i].w&&a[j].s>a[i].s)
{
if(dp[j]+>dp[i])
{
dp[i]=dp[j]+;
pre[i]=j;
}
}
}
}
int cou=;
int pos=-;
for(int i=;i<cnt;i++)
{
if(dp[i]>cou)
{
cou=dp[i];
pos=i;
}
}
if(cou==)
{
printf("%d %d\n",,);
return ;
}
cout<<cou<<endl;
Print(pos);
return ;
}

【教训】

while(scanf("%d%d",&a[cnt].w,&a[cnt].s)!=EOF)
{
a[cnt].id=++cnt;
}

是不对的,先算++cnt,前面的cnt已经加一了

【最长上升子序列记录路径(n^2)】HDU 1160 FatMouse's Speed的更多相关文章

  1. HDU - 1503 最长公共子序列记录路径

    题意:先给两个水果的名字然后得出一个最短的序列包含这两个词. 思路:我一开始的思路是先求出最长公共子序列,然后做一些处理将其他的部分输出来:两种水果的字符串和最长公共子序列的字符串这三个字符串做对比, ...

  2. HDU 1160 FatMouse's Speed 动态规划 记录路径的最长上升子序列变形

    题目大意:输入数据直到文件结束,每行两个数据 体重M 和 速度V,将其排列得到一个序列,要求为:体重越大 速度越低(相等则不符合条件).求这种序列最长的长度,并输出路径.答案不唯一,输出任意一种就好了 ...

  3. F - LCS 题解(最长公共子序列记录路径)

    题目链接 题目大意 给你两个字符串,任意写出一个最长公共子序列 字符串长度小于3e3 题目思路 就是一个记录路径有一点要注意 找了好久的bug 不能直接\(dp[i][j]=dp[i-1][j-1]+ ...

  4. hdu 1160 FatMouse's Speed(最长不下降子序列+输出路径)

    题意: FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to ...

  5. HDU 1160 FatMouse's Speed(要记录路径的二维LIS)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. 题解报告:hdu 1160 FatMouse's Speed(LIS+记录路径)

    Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove th ...

  7. HDU 1160 FatMouse's Speed (动态规划、最长下降子序列)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. HDU - 1160 FatMouse's Speed 动态规划LIS,路径还原与nlogn优化

    HDU - 1160 给一些老鼠的体重和速度 要求对老鼠进行重排列,并找出一个最长的子序列,体重严格递增,速度严格递减 并输出一种方案 原题等于定义一个偏序关系 $(a,b)<(c.d)$ 当且 ...

  9. hdu 1160 FatMouse's Speed (最长上升子序列+打印路径)

    Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove th ...

随机推荐

  1. Spark MLlib编程API入门系列之特征提取之主成分分析(PCA)

    不多说,直接上干货! 主成分分析(Principal Component Analysis,PCA), 将多个变量通过线性变换以选出较少个数重要变量的一种多元统计分析方法. 参考 http://blo ...

  2. nodejs on raspi

    一. https://cnodejs.org/topic/54032efa9769c2e93797cd06 其中的 “安装Node.js” 一节 注意事项: 1. 它用的是v0.10.26(很早的版本 ...

  3. archsummit_bj2014

    http://bj2014.archsummit.com/schedule.html 大会日程 时间 2014年12月19日 会议室 二号会议厅 7:45 入场注册 8:45 开场致辞 9:30 论高 ...

  4. AJPFX关于读取properties 配置文件 返回属性值

    :Properties的概述        * Properties 类表示了一个持久的属性集.        * Properties 可保存在流中或从流中加载.        * 属性列表中每个键 ...

  5. 深入理解Java的整型类型:如何实现2+2=5?

    先看下这段神奇的Java代码: public static void main(String[] args) throws Exception { doSomethingMagic(); System ...

  6. python 字符与字节 json序列和反序列及支持的类型

    b = b"demo" s = "demo" # 字符串转字节 s = bytes(s, encoding = "utf8") s = st ...

  7. JS 中的事件绑定、事件监听、事件委托是什么?

    在JavaScript的学习中,我们经常会遇到JavaScript的事件机制,例如,事件绑定.事件监听.事件委托(事件代理)等.这些名词是什么意思呢,有什么作用呢? 事件绑定 要想让 JavaScri ...

  8. 平时有没有使用xml和json

    平时有没有使用xml和json,在ajax交互中,哪一种更易于开发和维护,js中怎么序列化JSON字符串? 有,json相比xml可读性和可扩张性好.编码及解码难度较低.在数据交互中带宽占用少,并且在 ...

  9. Qt setWindow setViewPort

    painter.setWindow(-50, -50, 100, 100); //表示x,y坐标不变,可视的窗口移动到(-50,-50)的位置.同时在x,y方向产生factorx= (window.w ...

  10. install mysql at linux

    cd /usr/local wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm rpm -ivh mysql5 ...