UVa 111 - History Garding
来源:互联网 发布:软件开发技术 编辑:程序博客网 时间:2024/06/08 13:36
题目链接 :UVa 111 History Garding
动态规划,最长公共子序列。很久之前做的一道题,今天整理东西把这篇也发上来。动态规划的题目掌握的不好,得加把劲。
/**LCS*/#include<iostream>#include<cstring>using namespace std;int x[30],y[30];int dp[30][30];int main(){ int n,temp; cin>>n; for(int i=1;i<=n;i++) { cin>>temp; x[temp]=i; } while(cin>>temp) { y[temp]=1; for(int i=2;i<=n;i++) { cin>>temp; y[temp]=i; } memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { if(x[i]==y[j]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } cout<<dp[n][n]<<endl; } return 0;}
0 0
- UVa 111 - History Garding
- UVa 111 - History Grading
- uva 111 History Grading
- [UVA 111] History Grading
- uva:111 - History Grading
- UVa 111 - History Grading
- UVa 111 - History Grading
- UVA 111 History Grading
- UVa 111 - History Grading
- Uva - 111 - History Grading
- UVa 111 - History Grading
- UVa 111 - History Grading
- Uva-111-History Grading
- UVa 111: History Grading
- UVA - 111 History Grading
- UVA 111 History Grading
- uva 111History Grading
- UVA 111 History Grading
- mysql基本操作
- Hibernate4.3.1 org.hibernate.service.jta.platform.spi.JtaPlatform 异常解决
- IDAPthon 钩子问题
- 午马今日出殡 妻女书信寄情:今生难放下
- udhcpd.conf配置文档参考--修改网卡设备名interface wlan1 以及最后的网卡固定ip就可以
- UVa 111 - History Garding
- hdu2433 spfa+mark[x][u][v]优化
- 浅谈排序算法之归并排序
- 中文倒序输出问题
- 2013年下半年总结
- ubuntu 多余内核清理
- Git入门指南十:应用标签
- libsvm matlab 2013a for mac10.9 配置
- Android Notification通知详解