cf B. Dima and Text Messages

http://codeforces.com/contest/358/problem/B

先按照题意说的构造一个字符串s,然后与对比的字符串T比较,看看在字符串T中顺序查找有没有字符串S的所有字符,有输出yes,否则输出no.

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 char str[1000100],s[30001000];
 7 int n;
 8 
 9 int main()
10 {
11     while(scanf("%d",&n)!=EOF)
12     {
13        int cnt;
14        s[0]='<';
15        s[1]='3';
16        cnt=2;
17        for(int i=1; i<=n; i++)
18        {
19            scanf("%s",str);
20            for(int j=0; j<(int)strlen(str); j++)
21            {
22                s[cnt++]=str[j];
23            }
24            s[cnt++]='<';
25            s[cnt++]='3';
26        }
27        scanf("%s",str);
28        int k=0;
29        for(int j=0; j<(int)strlen(str); j++)
30        {
31            if(s[k]==str[j])
32            {
33                k++;
34            }
35        }
36        if(k==cnt)
37        {
38            printf("yes
");
39        }
40        else printf("no
");
41     }
42     return 0;
43 }
View Code
原文地址:https://www.cnblogs.com/fanminghui/p/3935754.html