百练 1936 ll in All 解题报告

1.链接:http://poj.grids.cn/practice/1936/

2.题目:

总时间限制:
1000ms
内存限制:
65536kB
描述
You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.

Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
输入
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The length of s and t will no more than 100000.
输出
For each test case output "Yes", if s is a subsequence of t,otherwise output "No".
样例输入
sequence subsequence

person compression

VERDI vivaVittorioEmanueleReDiItalia

caseDoesMatter CaseDoesMatter

样例输出
Yes

No

Yes

No

3.代码:

 1 #include <iostream>

 2 #include <cstdio>

 3 #include <cstring>

 4 #include <cstdlib>

 5 using namespace std;

 6 int main()

 7 {

 8     //freopen("F:\\input.txt","r",stdin);

 9     

10     

11     char s[100001],t[100001];

12     while(scanf("%s %s",s,t) != EOF)

13     {

14         int len1 = strlen(s);

15         int len2 = strlen(t);

16         int i,j;

17         

18         i = 0;j = 0;

19         while(i < len1 && j < len2)

20         {

21             if(s[i] == t[j]) i++;

22             j++;

23         }

24         if(i >= len1) cout<<"Yes"<<endl;

25         else cout<<"No"<<endl;

26     }

27     return 0;

28 }

4.思路:

1.使用scanf("%s %s",s,t) != EOF判断是否结束

你可能感兴趣的:(in)