uva 111 - History Grading(LCS)
来源:互联网 发布:刀具长度补偿怎么编程 编辑:程序博客网 时间:2024/06/06 00:04
此题的题目意思让我纠结了好久。。就是给出的是按照事件1-n分别对应的时间,而要求的则是根据时间从1-n的最长公共子事件。。
其实就是转换下就好了,把时间作为变量,值为事件的编号就是一个最基础的LCS了。
AC代码:
#include<cstdio>#include<ctype.h>#include<algorithm>#include<iostream>#include<cstring>#include<vector>#include<stack>#include<cmath>#include<queue>#include<set>#include<ctime>using namespace std;#define NMAX 100005#define ll long longint dp[25][25];int a[25],b[25];int main(){// freopen("input.txt","r",stdin);// freopen("o1.txt","w",stdout); int i,j,n,temp; scanf("%d",&n); for(i = 1; i <= n; i++) { scanf("%d",&temp); a[temp] = i; } while(~scanf("%d",&temp)) { b[temp] = 1; for(i = 2; i <= n; i++) { scanf("%d",&temp); b[temp] = i; } memset(dp,0,sizeof(dp)); for(i = 1; i <= n; i++) for(j = 1; j <= n; j++) if(a[i] == b[j]) dp[i][j] = dp[i-1][j-1]+1; else dp[i][j] = max(dp[i][j-1],dp[i-1][j]); printf("%d\n",dp[n][n]); } return 0;}
0 0
- uva 111 - History Grading(LCS)
- Uva 111-History Grading(DP/LCS)
- UVA - 111 - History Grading (LCS)
- uva 111 - History Grading LCS
- uva 111 History Grading(LCS)
- UVA 111 History Grading 【lcs】
- uva History Grading lcs
- UVA - 111 History Grading (动态规划:LCS)
- uva 111 History Grading(动态规划:LCS)
- UVA 111 History Grading(dp + LCS)
- UVa 111 History Grading (DP&LCS)
- History Grading(uva 111)
- UVa 111 - History Grading
- uva 111 History Grading
- [UVA 111] History Grading
- uva:111 - History Grading
- UVa 111 - History Grading
- UVa 111 - History Grading
- UITextView
- UIView属性
- ACdream Online Judge 1093
- JavaScript程序应该由桃园三结义组成
- 深入分析 Java I/O 的工作机制
- uva 111 - History Grading(LCS)
- 文本属性Attributes
- JDK安装及环境变量配置
- 哈哈,做题了
- APUE笔记-0说明
- java同步机制
- SSAS下玩转PowerShell
- POJ 3225 Roadblocks
- Arcgis10.0安装遇到错误1935