LCS、LIS、LICS
文章平均质量分 76
饿狼干爹
理想是丰满的,现实是骨干的
展开
-
LCS(最长公共子序列)和dp(动态规划)
参照:v_JULY_v 最长公共子序列定义: 注意最长公共子串(Longest CommonSubstring)和最长公共子序列(LongestCommon Subsequence, LCS)的区别:子串(Substring)是串的一个连续的部分,子序列(Subsequence)则是从不改变序列的顺序,而从序列中去掉任意的元素而获得的新序列;更简略地说,前者(子串原创 2015-04-30 12:15:49 · 3765 阅读 · 0 评论 -
杭电1159(Common Subsequence)LCS和dp
点击打开杭电1159Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of原创 2015-04-30 12:39:54 · 779 阅读 · 0 评论 -
杭电1503(Advanced Fruits)
点击打开杭电1503Problem DescriptionThe company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times thi原创 2015-04-30 14:06:20 · 1125 阅读 · 0 评论 -
杭电1423(Greatest Common Increasing Subsequence)
点击打开杭电1423Problem DescriptionThis is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence. InputEach sequence is described with M - its length (1原创 2015-05-07 15:07:00 · 916 阅读 · 0 评论 -
杭电1513(Palindrome)
点击打开杭电1513Problem DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given原创 2015-05-07 13:56:38 · 774 阅读 · 0 评论 -
杭电1257(最少拦截系统)dp方法
点击打开杭电1257最长递增子序列长度直接模板(最长递增子序列)代码实现:import java.util.Scanner;class P1257 { static int n; static int[] dp,a; public static void main(String[] args) { Scanner sc=new Scanner(Sys原创 2015-05-07 15:38:38 · 927 阅读 · 0 评论 -
【模板】最长公共子序列
[cpp] view plaincopy#include #include #include using namespace std; char s1[1000],s2[1000]; int len1,len2,dp[1000][1000],mark[1000][1000];//如果数据太大,dp数组可以考虑滚动数组转载 2015-05-07 14:21:38 · 495 阅读 · 0 评论 -
【模板】最长递增子序列
一般情况:[cpp] view plaincopy#include #include #include using namespace std; int a[1005],dp[1005],n; int LIS() { int i,j,ans,m; dp[1] = 1转载 2015-05-07 14:20:07 · 648 阅读 · 0 评论 -
【模板】最长递增公共子序列
二维:[cpp] view plaincopy#include #include #include using namespace std; int n,m,a[505],b[505],dp[505][505]; int LICS() { int MAX,i,j;转载 2015-05-07 14:20:58 · 645 阅读 · 0 评论