试着拍了一道模板题

dp开了500,开100会超时.....

string类型中间有空格会判为结束

#include<algorithm> -->min,max函数的头文件

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{
string s,t;
int dp[][];
while(cin>>s)
{
int i,j,m=,n=;
memset(dp,,sizeof(dp));
n=s.length();
cin>>t;
m=t.length();
for(i=;i<n;i++)
{
for(j=;j<m;j++)
{
if(s[i]==t[j])
{
dp[i+][j+]=dp[i][j]+;
}
else
{
dp[i+][j+]=max(dp[i][j+],dp[i+][j]);
}
}
}
cout<<dp[n][m]<<endl;
}
return ;
}

HDU 1159 裸最长公共子串的更多相关文章

  1. HDU 1159.Common Subsequence-最长公共子序列(LCS)

    Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  2. hdu 1159求最长公共子序列

    题目描述:给出两个字符串,求两个字符串的公共子序列(不是公共子串,不要求连续,但要符合在原字符串中的顺序) in: abcfbc abfcab programming contest abcd mnp ...

  3. HDU 1159 LCS最长公共子序列

    #include <cstdio> #include <cstring> using namespace std; ; #define max(a,b) a>b?a:b ...

  4. HDU 1503 带回朔路径的最长公共子串

    http://acm.hdu.edu.cn/showproblem.php?pid=1503 这道题又WA了好几次 在裸最长公共子串基础上加了回溯功能,就是给三种状态各做一个 不同的标记.dp[n][ ...

  5. HDU 1403 Longest Common Substring(后缀数组,最长公共子串)

    hdu题目 poj题目 参考了 罗穗骞的论文<后缀数组——处理字符串的有力工具> 题意:求两个序列的最长公共子串 思路:后缀数组经典题目之一(模版题) //后缀数组sa:将s的n个后缀从小 ...

  6. HDU 1403 Longest Common Substring(最长公共子串)

    http://acm.hdu.edu.cn/showproblem.php?pid=1403 题意:给出两个字符串,求最长公共子串的长度. 思路: 刚开始学后缀数组,确实感觉很难,但是这东西很强大,所 ...

  7. 最长公共子序列&最长公共子串

    首先区别最长公共子串和最长公共子序列  LCS(计算机科学算法:最长公共子序列)_百度百科 最长公共子串,这个子串要求在原字符串中是连续的.而最长公共子序列则并不要求连续. 最长公共子序列: http ...

  8. SCOJ 4493: DNA 最长公共子串 后缀自动机

    4493: DNA 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4493 Description Deoxyribonucleic acid ( ...

  9. 【wikioi】3160 最长公共子串(后缀自动机)

    http://codevs.cn/problem/3160/ sam的裸题...(之前写了spoj上另一题sam的题目,但是spoj被卡评测现在还没评测完QAQ打算写那题题解时再来详细介绍sam的.. ...

随机推荐

  1. 自然语言16.1_Python自然语言处理学习笔记之信息提取步骤&分块(chunking)

    QQ:231469242 欢迎喜欢nltk朋友交流 http://www.cnblogs.com/undercurrent/p/4754944.html 一.信息提取模型 信息提取的步骤共分为五步,原 ...

  2. HTML学习笔记——post表单

    1>form1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...

  3. Centos系统查看CPU有关信息

    top命令按1,看到几个CPU就代表是几核的. 查看CPU有几颗逻辑cpu,4代表有4个逻辑CPU,同时CPU的型号也打印出了,服务器一般都是至强的CPU [root@svn ~]# cat /pro ...

  4. [Redis]通过代码配置Redis

    查看了文档https://azure.microsoft.com/en-us/documentation/articles/cache-how-to-scale/,发现可以使用代码来配置Redis,所 ...

  5. MathML + MathJax在网页中插入公式

    http://www.mathjax.org/download/ http://www.w3.org/Math/Software/mathml_software_cat_editors.html ht ...

  6. php基础语句2

    计算一个月有多少天 $count = date("t",strtotime("2014-09-01")); // 一个月有多少天

  7. msbuild FileSysExcludeFiles

    <?xml version="1.0" encoding="utf-8"?> <!-- This file is used by the pu ...

  8. centos 安装 svn-1.9.4

    wget http://mirrors.cnnic.cn/apache/subversion/subversion-1.9.4.tar.gzwget http://mirror.bit.edu.cn/ ...

  9. [git]添加项目到git

    写在前面 一直在想把代码托管到git上面,一直没有去研究,最近发现自己写的demo,好多都找不到了,实在是没办法了,耐下心研究了下git.这里通过添加了自己做的demo,算是也是学习下git的操作吧. ...

  10. linux下如何使用sftp命令【转】

    linux下如何使用sftp命令 from:   http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888391.html sftp 是一个 ...