UVA 10066 The Twin Towers 双塔 LCS,dp
来源:互联网 发布:ubuntu ssh远程登录 编辑:程序博客网 时间:2024/06/05 09:44
题意:求最长公告子序列。
裸体,压缩了空间做的,O(n^2)做法,有空研究下nlogn做法。
代码:
/** Author: illuz <iilluzen[at]gmail.com>* Blog: http://blog.csdn.net/hcbbt* File: uva10066.cpp* Create Date: 2013-09-21 09:31:21* Descripton: dp, LCS */#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 101;int n, m, dp[2][MAXN], a[MAXN], b[MAXN];int main() {int cas = 0, k = 1;while (scanf("%d%d", &n, &m) && (n || m)) {for (int i = 1; i <= n; i++)scanf("%d", &a[i]);for (int j = 1; j <= m; j++) {scanf("%d", &b[j]);dp[0][j] = dp[1][j] = 0;}for (int i = 1; i <= n; i++) {k = !k;for (int j = 1; j <= m; j++)if (a[i] == b[j])dp[k][j] = max(dp[!k][j - 1] + 1, dp[k][j]);elsedp[k][j] = max(dp[k][j - 1], dp[!k][j]);}printf("Twin Towers #%d\n", ++cas);printf("Number of Tiles : %d\n\n", dp[k][m]);}return 0;}
- UVA 10066 The Twin Towers(dp + LCS)
- UVa 10066 The Twin Towers (DP&LCS)
- UVA.10066 The Twin Towers (DP LCS)
- UVA 10066 The Twin Towers 双塔 LCS,dp
- uva 10066 - The Twin Towers(LCS)
- UVA 10066 The Twin Towers (LCS)
- UVA 10066 The Twin Towers LCS ,Commencel
- uva--10066The Twin Towers +dp
- UVa 10066 - The Twin Towers(LCS水题)
- UVA - 10066 - The Twin Towers (动态规划, LCS)
- uva 10066 The Twin Towers(动态规划:LCS)
- uva10066 - The Twin Towers(dp,lcs)
- UVA 10066 - The Twin Towers
- uva 10066 The Twin Towers
- UVA 10066 The Twin Towers
- UVA 10066 The Twin Towers
- UVa 10066 - The Twin Towers
- UVa 10066 - The Twin Towers
- Matlab矩阵操作
- 9-patch教程
- 开发人员应该了解的外国网站
- shell脚本的编码问题
- Linux wext和nl80211接口简介
- UVA 10066 The Twin Towers 双塔 LCS,dp
- CODE 38: Unique Binary Search Trees
- 常见的字符串操作(C语言实现)
- ME525+在线 刷机
- Java观察者模式
- hdu - 1251 - 统计难题(Trip)
- [转]互联网系统架构的演进
- poj1007 qsort快排
- 浅析阿里云校招笔试题目之投骰子