英语题目作业(29)

原题:

Zipper

 1000ms  32768K

描述:

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".

输入:

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, 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.

样例输入:

3
cat tree tcraete
cat tree catrtee
cat tree cttaree

样例输出:

Data set 1: yes
Data set 2: yes
Data set 3: no

(链接:Zipper | JXNUOJ

翻译:

给你3个字符串,你需要判断第三个字符串是否是由前两个字符串的元素联合构成。前两个字符串可以任意混合,但是必须保持最初的顺序。

例如,"tcraete" 可看成是由 "cat" 和 "tree"构成:

字符串A:cat

字符串B:   tree

字符串C: tcraete

如你所见,我们可以从前两个字符串里选元素构成第三个元素。

第二个例子,"catrtee" 也可看成由 "cat" 和 "tree"构成:

字符串A:cat

字符串B:   tree

字符串C: catrtee

注意,“cat”和“tree"不能构成"cttaree" .

输入:

第一行输入包括一个从1到1000的正整数,代表测试组数。每一个测试数组是独立的。测试数组出现在后几行,一行一组。

对于每组数据,是3个字符串输入在同一行,中间由一个空格隔开。所有字符串仅由大小写字母组成。第三个字符串的长度总是等于前两个字符串长度之和。前两个字符串长度属于1到200之间。

输出:

对于每组数据,输出:

Data set n: yes
如果第三个字符串可以由前两个构成,否则输出:

Data set n: no

当然,n要被具体数据的组数代替。看下面的样例。
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值