【DP】UVA 10131 Is Bigger Smarter? LIS
来源:互联网 发布:realtek mac 驱动 编辑:程序博客网 时间:2024/06/05 08:14
排序后dp
写代码的速度还不够快。。。
</pre><pre name="code" class="cpp">#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <string>#include <iostream>#include <algorithm>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>#define cler(arr, val) memset(arr, val, sizeof(arr))#define IN freopen ("in.txt" , "r" , stdin);#define OUT freopen ("out.txt" , "w" , stdout);typedef long long LL;const int MAXN = 111;//点数的最大值const int MAXM = 20006;//边数的最大值const int INF = 11521204;const int mod=1000000007;struct node{ int x,y,num;}a[1999];bool cmp1(node h,node w){ if(h.x==w.x) return h.y>w.y; return h.x<w.x;}int dp[1111],out[1111];int print(int x){ if(out[x]!=0) print(out[x]); printf("%d\n",a[x].num);}int main(){ int n=1; // IN; while(scanf("%d%d",&a[n].x,&a[n].y)!=EOF) { a[n].num=n; n++; } cler(out,0); sort(a+1,a+n+1,cmp1); for(int i=1;i<n;i++) { dp[i]=1; // printf("%d %d %d\n",a[i].x,a[i].y,a[i].num); for(int j=1;j<i;j++) { if(a[i].x>a[j].x&&a[i].y<a[j].y&&dp[j]+1>dp[i]) { dp[i]=dp[j]+1; out[i]=j; } } } int ans=0,p=0; for(int i=1;i<n;i++) { if(dp[i]>ans) ans=dp[i],p=i; } printf("%d\n",ans); print(p); return 0;}
0 0
- UVa 10131 Is Bigger Smarter? (DP&LIS)
- 【DP】UVA 10131 Is Bigger Smarter? LIS
- UVA 10131 Is Bigger Smarter? DP
- UVA 10131 Is Bigger Smarter ? DP ,Commencel
- UVA 10131 Is Bigger Smarter? (DP)
- Is Bigger Smarter? - UVa 10131 dp
- UVA 10131 Is Bigger Smarter?(DP)
- Uva 10131-Is Bigger Smarter?(DP)
- uva--10131Is Bigger Smarter? +dp
- UVA - 10131 - Is Bigger Smarter? (动态规划,LIS)
- Uva 10131 Is Bigger Smarter? (LIS,打印路径)
- UVa 10131 Is Bigger Smarter?
- UVa 10131 Is Bigger Smarter?
- UVA 10131 - Is Bigger Smarter
- uva 10131 Is Bigger Smarter?
- uva:10131 - Is Bigger Smarter?
- uva 10131 Is Bigger Smarter?
- UVA 10131 Is Bigger Smarter?
- maven 热部署 改了类之后不用重新启动 提高开发效率
- Evaluate the value of an arithmetic expression in Reverse Polish Notation.
- Linux进程间通信——管道(二)
- zoj 2001 Adding Reversed Numbers
- yum [Errno 256] No more mirrors to try 解决方法
- 【DP】UVA 10131 Is Bigger Smarter? LIS
- python3.3中urllib.request.open问题
- SimpleDateFormat的parse()与format()
- python操作mysql数据库
- hdu3336
- android activity与fragment的生命周期详细研究
- webdev.dev 已停止工作解决办法
- inline-block元素的空白间距解决方法
- 字符串排序