百練1936 ll in All解題報告

4779 ワード

1.リンク:http://poj.grids.cn/practice/1936/
2.タイトル:
総時間制限:
1000 ms
メモリ制限:
65536 kB
説明
You have devised a new encryption technique which encodes a message by inserting between its characters racters randygeners streings.Because of pending patens well not diuses theingnersit is necessary to write a program that checks if the message is really encoded in the final string.
Gven two stings and t,you have to decide whether s s is a subsequence of t,i.e.if You can remove characters from t such that the concatent of the remaning characters.s.
入力
The input contains several testcases.Each is specified by two stings,t of alphanumeric ASCII characters separated byホワイトパス.The length of s and t will no more than 100000.
出力
For each test case output“Yes”,if s is a subsequence of t,otherswise out put“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は終了するかどうかを判断する。