Codeforces Round #208 (Div. 2) B. Dima and Text Messages
来源:互联网 发布:工业机器人控制软件 编辑:程序博客网 时间:2024/05/01 21:32
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.
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.
In a single line, print "yes" (without the quotes), if Dima decoded the text message correctly, and "no" (without the quotes) otherwise.
3iloveyou<3i<3love<23you<3
yes
7iamnotmaininthefamily<3i<>3am<3the<3<main<3in<3the<3><3family<3
no
Please note that Dima got a good old kick in the pants for the second sample from the statement.
注意,一定要有<3
#include <iostream>#include <stdio.h>#include <string>#include <string.h>using namespace std;int n;string ans,an;char str[100050];int main(){ int n; while(scanf("%d",&n)!=EOF){ ans="<3"; for(int i=0;i<n;i++){ scanf("%s",str); ans+=str; ans+="<3"; } scanf("%s",str); an=str; int i=0,j=0,leni=ans.length(),lenj=an.length(); while(i<leni&&j<lenj){ if(ans[i]==an[j]){ i++,j++; } else j++; } if(i==leni) printf("yes\n"); else printf("no\n"); } return 0;}
- Codeforces Round #208 (Div. 2) B. Dima and Text Messages
- Codeforces Round #208 (Div. 2) B Dima and Text Messages
- Codeforces Round #208 (Div. 2) B. Dima and Text Messages
- Codeforces Round #208 (Div. 2) Dima and Text Messages
- B. Dima and Text Messages
- Codeforces 358B - Dima and Text Messages 字符串
- Codeforces —— 358B Dima and Text Messages
- Codeforces Round #229 (Div. 2) B. Inna, Dima and Song
- Codeforces Round #229 (Div. 2) B. Inna, Dima and Song
- Codeforces Round #229 (Div. 2)B. Inna, Dima and Song
- Codeforces Round #229 (Div. 2) B. Inna, Dima and Song
- Codeforces Round #262 (Div. 2)B. Little Dima and Equation
- Codeforces Round #262 (Div. 2) B. Little Dima and Equation
- Codeforces Round #229 (Div. 2)B. Inna, Dima and Song
- Codeforces Round #262 (Div. 2) B. Little Dima and Equation
- Codeforces Round #208 (Div. 2) A_ Dima and Continuous Line
- Codeforces Round #208 (Div. 2) D. Dima and Hares
- Codeforces Round #208 (Div. 2) A. Dima and Continuous Line
- Codeforces Round #208 (Div. 2) A. Dima and Continuous Line
- 计算机网络笔试题
- switch语句分段函数求值
- 2014年计算机求职总结--准备篇
- MySQL数据库锁介绍
- Codeforces Round #208 (Div. 2) B. Dima and Text Messages
- 动态库简介
- switch语句构造菜单
- UVa 11294 Wedding (two SAT 输出解)
- 使用R进行数据可视化套路之-直方图
- android编译到系统
- virtualBox 串口的设置方法
- switch语句 计算个人所得税和税后收入
- latex分文件编写技巧