#K93197. Validate Marco's Encoded Message
Validate Marco's Encoded Message
Validate Marco's Encoded Message
Marco's encryption process takes an original message consisting of n words and produces an encoded message. In the encoding, each word from the original message is wrapped with asterisks, i.e., transformed into *word*
. These transformed words appear in order in the encoded message, but may have arbitrary characters in between.
Your task is to determine if a given encoded message could be produced by Marco's encryption process. Formally, given an integer n, a list of n words, and an encoded message, verify that the encoded message contains, in order, each of the substrings *word*
(for each word in the list). If it does, output "yes"; otherwise, output "no".
Note: There are no restrictions on the characters that may appear between the valid substrings.
The pattern can be described using the following regular expression in LaTeX notation:
$$.*\,\*w_1\*\,.*\,\*w_2\*\,.*\,\ldots,.*\,\*w_n\*.* $$where \(w_1, w_2, \ldots, w_n\) are the original words.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer
n
denoting the number of words in the original message. - The next
n
lines each contain one word. - The last line contains the encoded message.
outputFormat
Output a single line to standard output (stdout) containing either yes
if the encoded message is valid, or no
otherwise.
3
find
the
treasure
*find*!34&*the*%$#*treasure*!
yes
</p>