hdu5707-Combine String(DP)
A string c is said to be the combine string of a and b if and only if c can be broken into two subsequences, when you read them as a string, one equals to a , and the other equals to b .
For example, ``adebcf'' is a combine string of ``abc'' and ``def''.
Each test case contains three strings a, b and c (the length of each string is between 1 and 2000).
是否可以对c串成功匹配(成功匹配则必然会匹配到c串的前i+j个位置)。
dp[i][j]==1则表示可以成功匹配
dp[i][j]==0则表示无法成功匹配
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=;
int dp[maxn][maxn];
int main()
{
string a,b,c;
while(cin>>a>>b>>c){
memset(dp,,sizeof(dp));
if(c.size()!=a.size()+b.size())
printf("No\n");
else{
dp[][]=;
for(int i=;i<=a.size();i++){
for(int j=;j<=b.size();j++){
if(a[i]==c[i+j]){
dp[i+][j]|=dp[i][j];
}
if(b[j]==c[i+j]){
dp[i][j+]|=dp[i][j];
}
}
}
if(dp[a.size()][b.size()]==){
printf("Yes\n");
}else{
printf("No\n");
}
}
}
return ;
}
hdu5707-Combine String(DP)的更多相关文章
- CodeForces - 710E Generate a String (dp)
题意:构造一个由a组成的串,如果插入或删除一个a,花费时间x,如果使当前串长度加倍,花费时间y,问要构造一个长度为n的串,最少花费多长时间. 分析:dp[i]---构造长度为i的串需要花费的最短时间. ...
- HDU 5707 Combine String (DP,LCS变形)
题意:给定三个字符串,问你第三个是不是由第一个和第二个组成的. 析:当时比赛是没有做出来啊...一直WA,就是没有判断长度,第一个和第二个和是不是和第三个一样,这个忘记... 我们用d[i][j]表示 ...
- hdu 4055 Number String(dp)
Problem Description The signature of a permutation is a string that is computed as follows: for each ...
- HDU4055 - number string(DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4055 思路:dp[i][j]表示处理前i个字符以j结尾可能的序列数. 当a[i]=='I'时,dp[i ...
- Educational Codeforces Round 16 E. Generate a String (DP)
Generate a String 题目链接: http://codeforces.com/contest/710/problem/E Description zscoder wants to gen ...
- Number String(DP)
题目: 题意: 给你一个字符串s,s[i] = 'D'表示排列中a[i] > a[i+1],s[i] = 'I'表示排列中a[i] < a[i+1]. 比如排列 {3, 1, 2, 7, ...
- LightOJ 1033 Generating Palindromes(dp)
LightOJ 1033 Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- 【CF1132F】Clear the String(动态规划)
[CF1132F]Clear the String(动态规划) 题面 CF 题解 考虑区间\(dp\). 增量考虑,每次考虑最后一个字符和谁一起删去,然后直接转移就行了. #include<io ...
- 最长公共子序列长度(dp)
/// 求两个字符串的最大公共子序列长度,最长公共子序列则并不要求连续,但要求前后顺序(dp) #include <bits/stdc++.h> using namespace std; ...
随机推荐
- Servlet 学习
3.1 概念 运行在服务器端的小程序 Servlet 就是一个接口 定义JAVA类被浏览器访问(Tomact 识别)的规则 将来 我们需要自定义一个类 实现servlet 接口 重写方法 3.2 快速 ...
- 使用FFMPEG进行一些视频处理(C#)视频合并、转码、获取时长
FFMPEG的强大无需多说,举几个用到的功能,直接贴代码了 还有更多命令用到时搜索即可 视频转码 ) { var args = "-y -i {0} -vcodec copy {1}&quo ...
- IrisSkin 单独控件样式设置 不使用皮肤样式
可以设置控件的Tag为this.skinEngine1.DisableTag [DefaultValue()] [Description("If you do not want skin t ...
- linux中的find命令常用场景
1.find file.txt 在当前目录下,查找file.txt是否存在 2.find . -name file.txt 在当前目录下,递归查找file.txt文件 ...
- 清除系统默认样式,文本样式,高级选择器(权重),边界圆角,a标签的四大伪类,背景图片
清除系统默认样式 大多系统预定义标签,有默认样式,不满足实际开发需求,反倒影响布局通常清除系统样式,利于开发 body,h1-h6,p,table { margin:; } ul { margin:; ...
- docker学习-----docker可视化portainer
docker的可视化操作界面portainer 1.创建一个挂载区 docker volume create portainer_data 2.安装( docker run -d - ...
- pycharm实用快捷键集锦
以下是本人需要记录的快捷键,并不针对大众,所以是断断续续补充的,大家看看图个乐呵就成! 生成代码块(Surround with):Ctrl + Alt + t . 历史浏览页面跳转:很多时候,我们需要 ...
- css Modules 使用
我目前常用的也就是引用类名,以及在需要修改某个ui组件原有的样式比较麻烦时,会使用 :global className{ color: red;}这样来修改... 更多请参考阮老师博客: http:/ ...
- webpack学习笔记——publicPath路径问题
output: { filename: "[name].js", path:path.resolve(__dirname,"build") } 如果没有指定pu ...
- Kotlin 检查空类型
Kotlin 会检查你定义的非空类型 如果运行过程中被赋空值了 会直接crash