CodeForces 157C Message
$dp$。
$dp[i][j]$表示$s[i]$到$s[j]$和$t[lent-1+i-j]$到$t[lent-1]$有$dp[i][j]$位相同,然后枚举一遍$dp[i][j]$就可以算出答案了。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std; const int maxn=;
char s[maxn],t[maxn];
int lens,lent;
int dp[maxn][maxn]; int main()
{
memset(s,,sizeof s);
memset(t,,sizeof t);
scanf("%s%s",s,t);
lens=strlen(s), lent=strlen(t); for(int i=lens;i<lens+lent;i++) s[i]='.';
lens=strlen(s); int ans=; for(int Len=;Len<=lent;Len++)
{
for(int i=;i<lens;i++)
{
int j=i+Len-;
if(j>=lens) continue;
if(j==i)
{
if(s[i]==t[lent-]) dp[i][j]=;
else dp[i][j]=;
ans=min(ans,j-i+-dp[i][j]+lent-(j-i+));
}
else
{
dp[i][j]=dp[i+][j];
if(s[i]==t[lent-+i-j]) dp[i][j]++;
ans=min(ans,j-i+-dp[i][j]+lent-(j-i+));
}
}
} printf("%d\n",ans); return ;
}
CodeForces 157C Message的更多相关文章
- CodeForces 156A Message(暴力)
A. Message time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- Eclipse 4.2 failed to start after TEE is installed
--------------- VM Arguments--------------- jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...
- Codeforces Round #396 (Div. 2) C. Mahmoud and a Message dp
C. Mahmoud and a Message 题目连接: http://codeforces.com/contest/766/problem/C Description Mahmoud wrote ...
- Codeforces Round #396 (Div. 2) C. Mahmoud and a Message
地址:http://codeforces.com/contest/766/problem/C 题目: C. Mahmoud and a Message time limit per test 2 se ...
- 【codeforces 766C】Mahmoud and a Message
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces 766C:Mahmoud and a Message(DP)
题目链接:http://codeforces.com/problemset/problem/766/C 题意 有一个长度为n的字符串,第二行有26个数字,位置1~26对应为a~z的字母,数值表示该字母 ...
- Codeforces 766C - Mahmoud and a Message
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces 766C Mahmoud and a Message 2017-02-21 13:57 62人阅读 评论(0) 收藏
C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
随机推荐
- leetcode第38题--Combination Sum
题目: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C ...
- .Net Framework基础知识
.net常识 .net framework是微软为开发应用程序而创建的一个富有革命性的新平台: .net可以用来开发windows应用程序,web应用程序,web服务和其它各种类型的程序. . ...
- 《STL源代码剖析》---stl_hash_set.h阅读笔记
STL仅仅规定接口和复杂度,对于详细实现不作要求.set大多以红黑树实现,但STL在标准规格之外提供了一个所谓的hash_set,以hash table实现.hash_set的接口,hash_tabl ...
- Android项目--Json解析
在过去的一段时间里,我希望做一个天气的应用,但是由于老版的天气接口已经不能用了.只能更新到2014年3月4日. 不过有些东西,哪来学习一下,也是可以的. 比如:http://m.weather.com ...
- 如何使用SetTimer MFC 不够具体
转会:http://blog.csdn.net/ellor/article/details/1714741 Timer事件,即定时器事件,是在游戏编程中.常常使用的一个事件.借助它能够产生定时运行动作 ...
- HTML的框架,表格
#2 HTML的框架,表格 [以下是个人笔记,由于水平有限,因此有错误的地方,希望M我.谢谢] 表格|表单|框架---------------表格:布局 ----现在很少用到好处: 适合做 ...
- 使用ServletConfig获得web.xml资源中的参数
适用:一些不需要再Servlet文件中初始化的可以使用,例如:数据库用户名和密码 //Servlet文件 //实例化ServletConfig对象 ServletConfig servletConf ...
- HTML框架集之Frameset与Iframe简单应用
首先我们要明白此框架集的作用: 实现在一个页面中访问多个html页面的目的Frameset的用法: //定义框架集<frameset><frame src="demo.ht ...
- FormsAuthentication登录ReturnUrl使用绝对路径
ASP.NET]更简单的方法:FormsAuthentication登录ReturnUrl使用绝对路径 被这个问题困扰多年,今天终于找到了更简单的解决方法,分享一下. 问题场景 假设我们在i.cn ...
- worker进程中线程的分类及用途
worker进程中线程的分类及用途 欢迎转载,转载请注明出版,徽沪一郎. 本文重点分析storm的worker进程在正常启动之后有哪些类型的线程,针对每种类型的线程,剖析其用途及消息的接收与发送流程. ...