#include<iostream>
#include<string>
using namespace std;
int dp[202][202];
string s1,s2,s3;
int main()
{
int n;
cin>>n;
for(int t=1;t<=n;t++)
{
cin>>s1>>s2>>s3;
memset(dp,0,sizeof(dp));
dp[0][0]=1;
for(int i=0;i<s1.size();i++)
if(s1[i]==s3[i])
dp[i+1][0]=1;
for(int i=0;i<s2.size();i++)
if(s2[i]==s3[i])
dp[0][i+1]=1;
for(int i=1;i<=s1.size();i++)
for(int j=1;j<=s2.size();j++)
{
if(dp[i-1][j]&&s1[i-1]==s3[i+j-1])
dp[i][j]=1;
if(dp[i][j-1]&&s2[j-1]==s3[i+j-1])
dp[i][j]=1;
}
printf("Data set %d: ",t);
cout<<(dp[s1.size()][s2.size()]?"yes":"no")<<endl;
}
return 0;
}
poj2192
最新推荐文章于 2018-03-21 20:30:13 发布