非连续子串匹配题,直接模拟
/** \brief poj 1936** \param date 2014/8/5* \param state AC* \return memory 804k time 0ms**/#include <iostream>
#include <fstream>
#include <cstring>using namespace std;const int MAXN=100000;
char s[MAXN];
char t[MAXN];int main()
{//cout << "Hello world!" << endl;//freopen("input.txt","r",stdin);while(scanf("%s%s",s,t)!=EOF){//if(s==null )int slen=strlen(s);int tlen=strlen(t);int i,j;/*连续子串匹配for(i=0;i<=tlen-slen;i++){for(j=0;j<slen;j++)if(s[j]!=t[i+j])break;//if(s[j]==t[i+j])continue;}if(j==slen)cout<<"Yes"<<endl;else cout<<"No"<<endl;*/i=0;j=0;while(t[j]!='\0'){if(s[i]==t[j++])i++;}if(s[i]!='\0')cout<<"No"<<endl;else cout<<"Yes"<<endl;}return 0;
}