CF10月25日比赛。(Dima and Text Messages)

B. Dima and Text Messages
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to each other.

Dima and Inna are using a secret code in their text messages. When Dima wants to send Inna some sentence, he writes out all words, inserting a heart before each word and after the last word. A heart is a sequence of two characters: the "less" characters (<) and the digit three (3). After applying the code, a test message looks like that: <3word1<3word2<3 ... wordn<3.

Encoding doesn't end here. Then Dima inserts a random number of small English characters, digits, signs "more" and "less" into any places of the message.

Inna knows Dima perfectly well, so she knows what phrase Dima is going to send her beforehand. Inna has just got a text message. Help her find out if Dima encoded the message correctly. In other words, find out if a text message could have been received by encoding in the manner that is described above.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of words in Dima's message. Next n lines contain non-empty words, one word per line. The words only consist of small English letters. The total length of all words doesn't exceed 105.

The last line contains non-empty text message that Inna has got. The number of characters in the text message doesn't exceed 105. A text message can contain only small English letters, digits and signs more and less.

Output

In a single line, print "yes" (without the quotes), if Dima decoded the text message correctly, and "no" (without the quotes) otherwise.

Sample test(s)
input
3
i
love
you
<3i<3love<23you<3
output
yes
input
7
i
am
not
main
in
the
family
<3i<>3am<3the<3<main<3in<3the<3><3family<3
output
no
Note

Please note that Dima got a good old kick in the pants for the second sample from the statement.

 

代码:

#include<iostream>  
#include<cstring>  
#include<string>  
#include<cstdio>  
#include<cmath>  
#include<algorithm>  
using namespace std;  
  
string a;  
string p;  
string tmp;  
  
int main()  
{  
    int n,i,j;  
    while(cin>>n)  
    {  
        a="<3";  //先加在最前面  
        for(i=0;i<n;i++)  
        {  
            cin>>tmp;  
            a=a+tmp;  
            a+="<3";  //每一串后面都加一个<3  
        }  
  
        //现在a串是最短长度的解  
        cin>>p;  
        int t=0,len=a.length();  
        int len1=p.length();
        for(i=0;i<len1;i++)  
        {  
            if(t==len) break;  
            if(p[i]==a[t])  
                t++;  
        }  
        if(t==len) puts("yes");  
        else puts("no");  
    }  
    return 0;  
}  

 

转载于:https://www.cnblogs.com/songacm/p/3390101.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值