HDU
来源:互联网 发布:胡门网络胡建伟 编辑:程序博客网 时间:2024/06/14 00:36
Combine String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2208 Accepted Submission(s): 623
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 to a , 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
题意: 有a、b、c三个串,当且仅当a、b都为c的字串时输出yes,否则输出no
#include <bits/stdc++.h>const int N = 2e3 + 10;int dp[N][N];char a[N], b[N], c[N];int main(){ while(~scanf("%s %s %s",a , b, c)) { memset(dp,0,sizeof(dp)); int flag=0; int la = strlen(a), lb = strlen(b), lc = strlen(c); dp[0][0] = 1; for(int i = 0;i <= la; i++){ for(int j = 0; j <= lb; j++){ if(a[i] == c[i+j]){ dp[i+1][j] |= dp[i][j]; } if(b[j]==c[i+j]){ dp[i][j+1] |= dp[i][j]; } } } if(dp[la][lb] && lc == la + lb) printf("Yes\n"); else printf("No\n"); }}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- select标签下option标签里value属…
- Javascript获取select下拉框选中的…
- HTML5读取本地文件
- AngularJS中的交互 $http
- 【AngularJs】---JSONP跨域访问数…
- HDU
- Elasticsearch数据导入
- 谷歌解决跨域问题
- CSS的组织和管理
- 博客园 首页 新随笔&nbs…
- JAVA互联网架构学习之Listener
- html5-angular多个图片同时上传
- 迅捷CAD转换器把pdf文件转为dwg文件
- html5多个图片同时上传相关逻辑