"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5707
来源:互联网 发布:winner2016淘宝造物节 编辑:程序博客网 时间:2024/06/08 14:33
Combine String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 17 Accepted Submission(s): 11
Problem Description
Given three strings a ,b and c , your mission is to check whether c is the combine string of a and b .
A stringc 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 toa , and the other equals to b .
For example, ``adebcf'' is a combine string of ``abc'' and ``def''.
A string
For example, ``adebcf'' is a combine string of ``abc'' and ``def''.
Input
Input file contains several test cases (no more than 20). Process to the end of file.
Each test case contains three stringsa ,b and c (the length of each string is between 1 and 2000).
Each test case contains three strings
Output
For each test case, print ``Yes'', if c is a combine string of a and b , otherwise print ``No''.
Sample Input
abcdefadebcfabcdefabecdf
Sample Output
YesNo
Source
"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场
Recommend
liuyiding | We have carefully selected several similar problems for you: 5711 5710 5709 5708 5700
题意s1 串 s2串 能够组成s3串。
dp
令f[i][j]代表s1用i了个位置,并且匹配,s2用了j个位置并且匹配。所以每次转移是
f[i-1][j] &&s1[i]==c[i+j] f[i][j]=1 or f[i][j-1]&&s2[j]==c[i+j]
f[i-1][j] &&s1[i]==c[i+j] f[i][j]=1 or f[i][j-1]&&s2[j]==c[i+j]
#include <iostream>#include <cmath>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;char s1[2005];char s2[2005];char s3[2005];int f[2005][2005];void work(){ f[0][0]=1; int i,j; int l1=strlen(s1+1); int l2=strlen(s2+1); int l3=strlen(s3+1); if(l1+l2!=l3) { cout<<"No"<<endl; return; } for(i=0; i<=l1; i++) { for(j=0; j<=l2; j++) { if(i&&j) f[i][j]=0; if(f[i-1][j] &&s3[i+j]==s1[i]&&i) f[i][j]=1; if(f[i][j-1]&&s3[i+j]==s2[j]&&j) f[i][j]=1; } } if(f[l1][l2]) cout<<"Yes"<<endl; else cout<<"No"<<endl;}int main(){ while(scanf("%s%s%s",s1+1,s2+1,s3+1)!=EOF) work(); return 0;}
0 0
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5707
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5702
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5703
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5704
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5705
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5706
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- HDU "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 1001-1006
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- HDU Fraction 2016中国大学生程序设计竞赛(长春)-重现赛
- HDU Triangle 2016中国大学生程序设计竞赛(长春)-重现赛
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场-1001-Solving Order
- HDU Harmonic Value Description 2016中国大学生程序设计竞赛(长春)-重现赛
- HDU Sequence I 2016中国大学生程序设计竞赛(长春)-重现赛
- 我毕业了
- java多线程---停止、暂停一个线程
- Android 设置 drawableLeft|Right|Top|Bottom
- bzoj1269 文本编辑器
- ArrayList集合内容查重
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5707
- self/super关键字/实例变量修饰符/description
- [INS-30131] 执行安装程序验证所需的初始设置失败[绝对解决]
- C++第6次作业
- Java内省和beanUtil
- tableau sdk java的测试
- Impala与Hive的比较
- iOS 证书权限分配
- 剑指offer19--依次打印队列二叉树中的元素