简单题,按题目要求,从前向后扫描一边,再从后向前扫描一边即可.
Source:
#include<iostream>
using namespace std;
char s1[110],s2[110];
int l1,l2;
int main()
{
int t,i,j;
for(cin>>t;t>0;--t)
{
cin>>s1>>s2;
l1=strlen(s1);
l2=strlen(s2);
for(i=0,j=0;i<l1 && j<l2;++i)
{
if(s2[j]==s1[i])++j;
}
if(j==l2)
{
cout<<"YES"<<endl;
continue;
}
for(i=0,j=l2-1;i<l1 && j>=0;++i)
{
if(s2[j]==s1[i])--j;
}
if(j<0)
{
cout<<"YES"<<endl;
}else
cout<<"NO"<<endl;
}
return 0;
}