

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The details of problem b in the acm pacific nw region programming contest held on november 13, 2004. The problem involves determining if the third string can be formed by combining the characters in the first two strings while maintaining their original order. The input consists of multiple data sets, each with three strings, and the output is a 'yes' or 'no' indicating whether the third string can be formed from the first two.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Page 1 of 2
Problem 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".
The Input (from file b.in) The first line of input file, b.in, contains a single positive integer from 1 through
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.
The Output (to stdout) 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.
Page 2 of 2
Sample input
3 cat tree tcraete cat tree catrtee cat tree cttaree
Sample output
Data set 1: yes Data set 2: yes Data set 3: no