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 ...
随机推荐
- JSON解析之Gson
1.Gson简介 Gson是一个将Java对象转为JSON表示的开源类库,由Google提供,并且也可以讲JSON字符串转为对应的Java对象.虽然有一些其他的开源项目也支持将Java对象转为JSON ...
- <图形图像,动画,多媒体> 读书笔记 --- 力学行为特性
UIKit力学行为包括了:重力(UIGravityBehavior),碰撞(UICollisionBehavior),吸附(UIAttachmentBehavior),推(UIPushBehavior ...
- 如何使用AdvancedInstaller在安装包中运行一个.bat文件
原文:如何使用AdvancedInstaller在安装包中运行一个.bat文件 1, 首先要保证你的Files and Folders模块下的Application Folder文件夹下包含你要运行 ...
- Add GUI to connect to SQL
(*********************************************************************************) (* *) (* Below i ...
- 【工作笔记二】ASP.NET MVC框架下使用MVVM模式
ASP.NET MVC框架下使用MVVM模式 原文:http://www.cnblogs.com/n-pei/archive/2011/07/21/2113022.html 对于asp.net mvc ...
- form-validation--表单验证插件
基于jquery的validationEngine表单验证插件,根据官网提示,该插件支持IE6-8,Chrome浏览器,火狐,Safari,Opera 10,但由于有使用到了css3的阴影和圆角样式, ...
- SHELL 近期学习
由于项目中很少使用到shell脚本所以.只是偶尔自学一点.慢慢积累.下面就把近段时间积累的发出来.学习. #sort sort 按首字母排序 sort -n 按数字大小 从小到大排序 sort -rn ...
- IIS7.5下的httpModules设置
部署到IIS7.5上httpModule不起作用了,原来是iis7里面的网站应用程序池使用了默认的“集成模式”,所以所有的http请求处理都托管给了 IIS,web.config里面的配置就不起效了. ...
- iOS基础 - 史上最难游戏
步骤一:隐藏状态栏 步骤二:屏幕适配 步骤三:设置窗口的根控制器为导航控制器,并且设置导航条和状态栏. 步骤四:搭建设置界面 步骤五:控制器连线 步骤六:搭建关卡控制器 加载pilst文件 创建关卡模 ...
- Binder机制,从Java到C (8. ServiceManager in Native)
在第三篇 Binder机制,从Java到C (3. ServiceManager in Java) 中,讲到ServiceManager的Stub端在Native,Proxy端在Java.实际上,还要 ...