uva111 History Grading
2016-07-31 16:57
239 查看
History Grading
Description
View Code
Description
#include <cstdio> #include <iostream> #include <cstring> #include <cstring> #include <cctype> using namespace std; const int maxn = 32; int dp[maxn][maxn]; int main() { int n, x; scanf("%d", &n); int a[maxn], b[maxn]; for(int i = 1; i<= n; i++) { scanf("%d", &x); a[x] = i; } while(scanf("%d", &x) != EOF) { b[x] = 1; for(int i = 2; i <= n; i++) { scanf("%d", &x); b[x] = i; } memset(dp ,0, sizeof(dp)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i] == b[j]){ dp[i+1][j+1] = dp[i][j] + 1; }else { dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]); } } } printf("%d\n", dp[n+1][n+1]); } return 0; }
View Code
相关文章推荐
- UVa 111 History Grading (最长公共子序列)
- UVa 111 - History Grading
- Uva 111 – History Grading
- UVA 111 History Grading
- UVA - 111 History Grading (动态规划:LCS)
- UVa 111 History Grading (最长公共子序列)
- uva 111 History Grading
- Uva 111 – History Grading
- UVa 111 - History Grading (by 最长公共子序列 )
- UVA-111 History Grading(dp+最长公共子序列)
- 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(dp + LCS)
- UVA - 111 History Grading
- UVA 111 - History Grading(动态规划)