soj 2796 Letter Deletion LCS
来源:互联网 发布:淘宝店铺怎么登录 编辑:程序博客网 时间:2024/06/03 21:03
题意:
删除后单词最长相等长度.
分析:
裸LCS.
code
#include <iostream>#include <cstdio>#include <cstring>#include <set>#include <map>#include <stack>#include <vector>#include <string>#include <queue>#include <cstdlib>#include <cmath>#include <algorithm>using namespace std;typedef pair<int, int> pii;typedef long long ull;typedef long long ll;typedef vector<int> vi;#define xx first#define yy second#define rep(i, a, n) for (int i = a; i < n; i++)#define sa(n) scanf("%d", &(n))#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;int dp[222][222];int main(void){ string a, b; while (cin >> a >> b) { for (int i = 1; i <= a.size(); i++) { for (int j = 1; j <= b.size(); j++) { dp[i][j] = max(dp[i - 1][j], max(dp[i][j - 1], dp[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? 1 : 0))); } } cout << dp[a.size()][b.size()] << endl; } return 0;}
0 0
- soj 2796 Letter Deletion LCS
- FZU 1502 Letter Deletion
- FZU 1502Letter Deletion
- FZU 1502 Letter Deletion
- PAT1015: Letter-moving Game(LCS)
- pat 1015. Letter-moving Game (35)(LCS)
- soj
- letter
- LCS
- LCS
- lcs
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- [Git]第六回 Git标签
- 仿微信群头像,自定义控件
- 百宝云开源商业化完整注册码系统——商业脚本作者必备系统
- java Executors源码简析
- Android - 重要知识点
- soj 2796 Letter Deletion LCS
- 阿里java常见面试题
- SCM代码的学习与优化
- IntentService的原理及使用
- 一种均匀分布不模糊的波纹效果实现。
- 在mac下安装mysql时 Access denied for user 'root'@'localhost' (using password: YES) 如何解决
- Hadoop的启动与停止
- ViewPager指示器实现
- Android开发:shape和selector和layer-list的(详细说明)