hdu 1160 DP
来源:互联网 发布:centos在线安装jdk1.7 编辑:程序博客网 时间:2024/05/20 15:38
最长上升序列+路径打印
#include<cstdio>#include<stdlib.h>#include<string.h>#include<string>#include<cmath>#include<cstring>#include<algorithm>#include<map>#include<set>#include<queue>#include<vector>using namespace std;int d[1005],f[1005];struct node{ int x,y; int num;}a[1005];bool cmp(const node& a1,const node& a2){ return a1.y<a2.y;}int main(){ int i,j,n,res,t;// freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout); //scanf("%d",&n); i=0; while(scanf("%d%d",&a[i].x,&a[i].y)!=EOF) { a[i].num=i; f[i]=i; i++; } n=i; res=0; sort(a,a+n,cmp); // printf("\n"); // for(i=0;i<n;i++) // printf("%d %d\n",a[i].x,a[i].y); for(i=0;i<n;i++){ d[i]=1; for(j=0;j<i;j++) { if(a[i].x<a[j].x&&d[j]+1>d[i]&&a[i].y>a[j].y){ d[i]=d[j]+1; f[a[i].num]=a[j].num; } if(d[i]>res){ res=d[i]; t=i; } } } // for(i=0;i<n;i++) // printf("%d ",d[i]); // printf("\n"); //for(i=0;i<n;i++) // printf("%d ",f[i]); printf("%d\n",res); int x=a[t].num; while(res--) { printf("%d\n",x+1); x=f[x]; } return 0;}
0 0
- hdu 1160 dp
- hdu 1160 DP
- hdu 1160 dp 入门
- HDU 1160 DP
- hdu 1160 dp水
- [DP-LIS] HDU 1160
- HDU DP
- DP? HDU
- DP? HDU
- DP? HDU
- 【dp】HDU
- 【dp】HDU
- 【dp】 HDU
- DP? HDU
- hdu 1160 DP 最长子序列问题
- hdu 1160 FatMouse's Speed (DP)
- HDU 1160 FatMouse's Speed DP
- HDU 1160 FatMouse's Speed(DP)
- 8086汇编:在内存单元中做表
- 自定义杨辉三角行数并打印
- Struts2结果类型的对比(redirect)与(redirectAction)
- 计算机与接口通信期末作业(国软)
- 备用
- hdu 1160 DP
- Sort Colors
- UVA 331 Mapping the Swaps
- [leetcode] 39& 40 Combination Sum I& II
- 树链剖分模板(基于点权,基于边权)
- UVA 10012 How Big Is It?
- Java 基于socket thread 简单聊天程序
- Andrid 之自动化测试工具 Monkeyrunner
- USACO 1.5 prime Palindromes 回文质数(vector的使用)