#include<iostream>#include<cstdio>#include<fstream>#include<algorithm>#include<cmath>#include<deque>#include<vector>#include<queue>#include<string>#include<cstring>#include<map>#include<stack>#include<set>usingnamespacestd;
structdate
{
char x;
structdate *left,*right;
};
int iox,hight,flag;
structdate *arr,*arr1;queue<struct date*>q;
string arr2,arr3,arr4;
voidcreat(struct date*& T,char k){
if(T==NULL)
{
T=(struct date *)malloc(sizeof(struct date));
T->x=k;
T->left=NULL;
T->right=NULL;
}
else
{
if(T->x>k)
creat(T->left,k);
else
creat(T->right,k);
}
}
voidcompare(struct date *T,struct date *T1){
if(T==NULL||T1==NULL)
return;
elseif(T->x!=T1->x)
{
flag=0;
return;
}
else
{
compare(T->left,T1->left);
compare(T->right,T1->right);
}
}
intmain(){
int i,n;
while(cin>>n)
{
if(n==0)
break;
arr=NULL;
cin>>arr2;
for(i=0;i<arr2.size();i++)
{
creat(arr,arr2[i]);
}
while(n--)
{
cin>>arr3;
arr1=NULL;
for(i=0;i<arr3.size();i++)
{
creat(arr1,arr3[i]);
}
flag=1;
compare(arr,arr1);
if(flag==0)
cout<<"NO"<<endl;
elseif(flag==1)
cout<<"YES"<<endl;
}
}
return0;
}
sdut二叉排序树
最新推荐文章于 2024-08-22 15:48:46 发布