码迷,mamicode.com
首页 >  
搜索关键字:nyoj 336 子序列    ( 6902个结果
UVA - 531Compromise(LIS)
题目:UVA - 531Compromise(LIS) 题目大意:给出两段话,找出里面最长的公共单词的子序列。并且输出任意一个子序列。 解题思路:LIS。 代码: #include #include const int N = 105; const int M = 35; char w1[N][M]; char w2[N][M]; int f[N][N]...
分类:其他好文   时间:2014-08-22 13:00:28    阅读次数:195
LCS 最长公共子序列
与Edit Distance问题类似, 纯dp状态转移方程如下在poj上找了一道题目 poj1458, 水过代码如下 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #...
分类:其他好文   时间:2014-08-22 12:52:28    阅读次数:204
Missile:双状态DP
题目 描述 Long , long ago ,country A invented a missile system to destroy the missiles from their enemy . That system can launch only one missile to destroy multiple missiles if the heights of all the...
分类:其他好文   时间:2014-08-22 00:26:05    阅读次数:218
leetcode Interleaving String
算是最长公共子序列问题吧,mark一下 class Solution { public: bool f[1000][1000]; bool isInterleave(string s1, string s2, string s3) { if(s1.size() + s2.size() != s3.size()) return false; ...
分类:其他好文   时间:2014-08-21 22:51:34    阅读次数:185
NYOJ 832 合并游戏
合并游戏时间限制:1000ms | 内存限制:65535KB难度:4描述大家都知道Yougth除了热爱编程之外,他还有一个爱好就是喜欢玩。某天在河边玩耍的时候,他发现了一种神奇的石子,当把两个石子放在一起的时候,后一个石子会消失,而且会蹦出一定数量的金币,这可乐坏了Yougth,但是他想得到最多的金...
分类:其他好文   时间:2014-08-21 22:38:24    阅读次数:273
子序列与子串问题总结
1、最长递增子序列 扩展:双duan...
分类:其他好文   时间:2014-08-21 17:19:44    阅读次数:167
算法题——最大连续子序列乘积
1 template 2 Comparable maxprod( const vector&v) 3 { 4 int i; 5 Comparable maxProduct = 1; 6 Comparable minProduct =...
分类:其他好文   时间:2014-08-21 13:17:24    阅读次数:217
UVA 437 The Tower of Babylon
题意:给n种立体块,每种有无限个,上面的块长宽必须小于下面的块,问最多可以搭建多高 思路:输入的时候小小处理下,把每个块各条边当高的情况存入结构体中,按升序排序,然后dp,比较求出最大值。。看好多代码都说什么最长上升子序列,感觉没有用到额,LIS的标记数组是用来存储相应长度的最小值的,没看出来哪里用上了额。。。数据范围小,直接就是dp了=。= #include #include #...
分类:其他好文   时间:2014-08-20 22:47:03    阅读次数:253
UVa 531 - Compromise
题目:给你两个文章,求里面最多的按顺序出现的单词。 分析:dp,LCS(最大公共子序列)。直接求最大公共子序列,每个单词当做一个元素即可;             注意记录路径:如果匹配成功记录前驱,否则取前面取得的最大值。 说明:注意输出时的格式,多打个空格WA了好几次才发现。 #include #include #include #include using namespac...
分类:其他好文   时间:2014-08-20 19:38:42    阅读次数:196
NYOJ 115 城市平乱
思路:最短路径算法决心用这道题好好练练最短路径~先附上flody算法,超时了代码:#include #define INF 99999using namespace std;int e[1001][1001];//地图,邻接矩阵储存int N,M,P,Q;int n[101];//代表部队驻扎的点v...
分类:其他好文   时间:2014-08-20 17:55:52    阅读次数:202
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!