hdu 1243 反恐训练营 lcs
来源:互联网 发布:域名叫什么好 编辑:程序博客网 时间:2024/04/28 18:03
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#define inf 0x3f3f3f3f#define LL long longusing namespace std;/************************************************designer:hltime:2016/11/15Exe.Time:780 msExe.Memory:18820 KB题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1243题意:亲切中文题题解:LCS裸todo:其实可以加个优化在上面 就是先把无关的子弹都排除掉。这样可以减少循环的次数************************************************/int dp[2100][2100];int main() { int i, j, k, l, m, n; int score[1200]; char type[2100], terror[2100], bullet[2100]; while (~scanf("%d\n", &n)) { memset(dp, 0, sizeof(dp)); memset(score, 0, sizeof(score)); scanf("%s", type); for (i = 0; i < n; i++) { scanf("%d", &score[type[i]]); } scanf("%*c"); scanf("%s", bullet); scanf("%s", terror); int bulletLen = strlen(bullet); int terrorLen = strlen(terror); for (i = 1; i <= bulletLen; i++) { for (j = 1; j <= terrorLen; j++) { if (bullet[i - 1] == terror[j - 1]) { dp[i][j] = max(dp[i - 1][j - 1] + score[terror[j - 1]], dp[i][j]); } else { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); } } } printf("%d\n", dp[bulletLen][terrorLen]); } return 0;}
0 0
- hdu 1243 反恐训练营--LCS
- hdu 1243 反恐训练营 lcs
- hdu 1243 反恐训练营 LCS变形
- HDU 1243 反恐训练营【LCS(dp)】
- HDU 1243 反恐训练营
- HDU 1243 反恐训练营
- hdu 1243 反恐训练营
- HDU 1243 反恐训练营
- hdu 1243 反恐训练营
- 反恐训练营 1243 (LCS 模板 好题)
- C++ OJ HDU 1243 反恐训练营
- hdu 1243 反恐训练营(DP+空间优化)
- HDU 1243反恐训练营(最长公共子序列)
- HDU 1243 反恐训练营(最长公共序列)
- HDU-1243 反恐训练营(最大公共子序列)
- hdu1243 反恐训练营(动态规划 LCS)
- hdu1243 反恐训练营
- HDU 1243 反恐训练营 (动态规划求最长公共子序列)
- 智能家居
- PHP之批处理文件内容
- String StringBuffer StringBuilder的区别
- Java_类_学习大纲
- 将文档一和文档二中的数字相加到第三个文档
- hdu 1243 反恐训练营 lcs
- C++之多态和虚函数
- Linux旅途(一)vim插件之nerdtree的坑
- POJ - 2182 Lost Cows【线段树】
- JDK安装与配置
- Android - OnTouchEvent()和setOnTouchListener()中的OnTouch()方法的区别?
- Android中的布局管理
- android studio编译警告:请使用 -Xlint:deprecation 重新编译
- 告诉你一个真实的袁世凯