light oj 1110 LCS 记录路径
来源:互联网 发布:手机 惯性导航算法 编辑:程序博客网 时间:2024/04/24 09:51
#include <stdio.h>#include <string.h>#include <algorithm>#pragma warning (disable : 4996)using namespace std;const int Max = 105;int dp[Max][Max];char s[Max][Max][Max];char str1[Max], str2[Max];int main(){int T, k, i, j;scanf("%d", &T);for (int t = 1; t <= T; t++){memset(s, 0, sizeof(s));scanf("%s %s", str1+1, str2+1);for (i = 1; str1[i]; i++){for (j = 1; str2[j]; j++){if (str1[i] == str2[j]){dp[i][j] = dp[i - 1][j - 1] + 1;for (k = 0; k < dp[i - 1][j - 1]; k++)s[i][j][k] = s[i - 1][j - 1][k];s[i][j][k] = str1[i];}else{if (dp[i - 1][j]>dp[i][j - 1]){dp[i][j] = dp[i - 1][j];strcpy(s[i][j], s[i - 1][j]);}else if (dp[i][j - 1] > dp[i - 1][j]){dp[i][j] = dp[i][j - 1];strcpy(s[i][j], s[i][j - 1]);}else{dp[i][j] = dp[i - 1][j];if (strcmp(s[i - 1][j], s[i][j - 1]) >= 0)strcpy(s[i][j], s[i][j - 1]);elsestrcpy(s[i][j], s[i - 1][j]);}}}}i--; j--;printf("Case %d: ", t);if (dp[i][j])puts(s[i][j]);else puts(":(");}return 0;}
0 0
- light oj 1110 LCS 记录路径
- Light OJ 1110 An Easy LCS (DP+路径记录)
- Light OJ 1110 - An Easy LCS (LCS+字典序最小路径记录)
- Light oj 1110 LCS带打印路径
- Light oj 1110 - An Easy LCS(LCS)
- light oj 1159 - Batman LCS
- light oj An Easy LCS
- light oj 1013 LCS 应用
- Light oj 1159 - Batman(三维 LCS)
- Light OJ 1157 LCS Revisited (DP)
- light oj 1033 - Generating Palindromes (LCS)
- light oj 1033 - Generating Palindromes 【LCS】
- light oj 1011 一个普通记录...(路径?)的状压dp
- Light OJ 1013 - Love Calculator(LCS+ 计方案数)
- Light OJ:1033 Generating Palindromes(LCS+回文字符串)
- Light oj 1157 - LCS Revisited(lcs 个数 记忆化搜索)
- POJ 2250--Compromise(LCS以及路径记录)
- poj2250 Compromise dp lcs 记录路径
- uCOS-III 基础
- IE浏览器在Javascript处理数组对象时出现数组个数不正确
- 高精度之n!(n<=10000)
- 贝尔数
- Android自定义ImageView实现图片缩放滑动,双击放大缩小,多点触控缩放
- light oj 1110 LCS 记录路径
- HDU 5371 Hotaru's problem(Manacher 求一序列三部分回文)
- hadoop远程调试
- System.currentTimeMillis()计算方式与时间的单位转换
- bzoj3585: mex
- Highways POJ 2485【Prim】
- oracle授权时“with admin option”与“with grant option”的区别
- C++ 对象数组
- 我的VIM配置(ubuntu)语法高亮 自动补全