POJ 2192 判断两个字符串是否能按顺序组合成第三个字符串 ZIPPER
来源:互联网 发布:淘宝口碑好的包包店铺 编辑:程序博客网 时间:2024/05/16 16:10
经典动态规划
现在对动态规划的子结构划分和子结构的理解,转移方程还没有明确的认识
Zipper
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9409 Accepted: 3218
Description
Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order.
For example, consider forming "tcraete" from "cat" and "tree":
String A: cat
String B: tree
String C: tcraete
As you can see, we can form the third string by alternating characters from the two strings. As a second example, consider forming "catrtee" from "cat" and "tree":
String A: cat
String B: tree
String C: catrtee
Finally, notice that it is impossible to form "cttaree" from "cat" and "tree".
For example, consider forming "tcraete" from "cat" and "tree":
String A: cat
String B: tree
String C: tcraete
As you can see, we can form the third string by alternating characters from the two strings. As a second example, consider forming "catrtee" from "cat" and "tree":
String A: cat
String B: tree
String C: catrtee
Finally, notice that it is impossible to form "cttaree" from "cat" and "tree".
Input
The first line of input contains a single positive integer from 1 through 1000. It represents the number of data sets to follow. The processing for each data set is identical. The data sets appear on the following lines, one data set per line.
For each data set, the line of input consists of three strings, separated by a single space. All strings are composed of upper and lower case letters only. The length of the third string is always the sum of the lengths of the first two strings. The first two strings will have lengths between 1 and 200 characters, inclusive.
For each data set, the line of input consists of three strings, separated by a single space. All strings are composed of upper and lower case letters only. The length of the third string is always the sum of the lengths of the first two strings. The first two strings will have lengths between 1 and 200 characters, inclusive.
Output
For each data set, print:
Data set n: yes
if the third string can be formed from the first two, or
Data set n: no
if it cannot. Of course n should be replaced by the data set number. See the sample output below for an example.
Data set n: yes
if the third string can be formed from the first two, or
Data set n: no
if it cannot. Of course n should be replaced by the data set number. See the sample output below for an example.
Sample Input
3cat tree tcraetecat tree catrteecat tree cttaree
Sample Output
Data set 1: yesData set 2: yesData set 3: no
///
- POJ 2192 判断两个字符串是否能按顺序组合成第三个字符串 ZIPPER
- poj2192 Zipper 两个字符串是否能构成第三个
- POJ 2192 Zipper(判断第3个字符串能否有前两个字符串组成) 水dp
- (字符串模式匹配4.7.10)POJ 2192 Zipper(判断第3个字符串能否有前两个字符串组成)
- POJ-2192 Zipper-DP-字符串
- POJ 2192 Zipper(字符串)
- j-判断能否通过两个字符串得到第三个
- 判断两个字符串是否匹配
- 判断两个字符串是否相等
- 判断两个字符串是否相同
- 判断两个字符串是否相等
- 判断两个字符串是否为兄弟字符串
- 判断两个字符串是否相等(换位字符串)
- 判断两个字符串是否为兄弟字符串
- 判断两个字符串是否是同分异构字符串
- Oracle 判断字符串是否能转成数字。
- 利用顺序栈判断字符串是否回文
- 函数: 判断两个字符串是否完全一样
- Dev ExpressDbEditors 中的cxDBComboBox cxDBPopupEdit 用下拉箭头选择录入的实现
- Android终端信息收集
- PCSC那事儿(三十四--PCSCD)
- 微软SQL Server数据库SQL语句导入导出大全
- iframe自适应大小
- POJ 2192 判断两个字符串是否能按顺序组合成第三个字符串 ZIPPER
- 父子对话,你想保卫啥
- oracle 字符集
- [转自网上]Java学习路线
- PCSC那事儿(三十五--PCSCD)
- diff patch 命令
- 要使问题进入可讨论的状态,就必须对所要讨论的问题尽可能加以明确的界定。
- PCSC那事儿(三十六--PCSCD)
- [ASP.NET]WebForm中的MessageBox.Show