试着拍了一道模板题

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. 安装beautifulsoup4

    python scripts下 pip install beautifulsoup4

  2. SQL日期格式转换

    CONVERT(nvarchar(20), [Date],101) as 'Date'    10/20/2016 CONVERT(nvarchar(20), [Date],102) as 'Date ...

  3. scrapy1_官网教程

    https://scrapy-chs.readthedocs.io/zh_CN/0.24/intro/tutorial.html 本篇文章主要介绍如何使用编程的方式运行Scrapy爬虫. 在开始本文之 ...

  4. Oracle创建表空间及用户

    1.sys dba登录 2.创建临时表空间 create temporary tablespace wf_temp tempfile 'C:\APP\ADMINISTRATOR\ORADATA\PLA ...

  5. 如何写好一篇高质量的paper

    http://blog.csdn.net/tiandijun/article/details/41775223 这篇文章来源于中科院Zhouchen Lin 教授的report,有幸读到,和大家分享一 ...

  6. C#----使用WindowsMediaPlayer 同时播放多个声音

    使用Windows Media Player 其实就是使用组件AxWindowsMediaPlayer. 添加两个引用:Interop.WMPLib.dll和AxInterop.WMPLib.dll. ...

  7. Podfile升级后的影响

    之前项目里用的Podfile都是版本 0.39 后面有一天电脑格盘重装以后cocoapods装的版本是 1.0.0.beta.6 那么问题来了,在下载或者clone一下项目后,经常是需要自己安装第三方 ...

  8. Quartz.NET总结(二)CronTrigger和Cron表达式

    Quartz.NET的任务调度,主要就是依靠CronTrigger和Cron表达式.Cron是已经在UNIX存在了很长一段时间,它有着强大和可靠的调度能力.CronTrigger类也正是是基于Cron ...

  9. How to save milliseconds to DB in NHibernate

    We need to configure Timestamp in Mapping. eg. Map(x => x.ResponseDate).CustomType("Timestam ...

  10. AuthenticationManager.SignOut() 无法注销用户的问题

    http://hadb.me/2015/03/23/authenticationmanager-signout-not-working/ 这文章不对, 我发现原因是不能有Response.Redire ...