fork(1) download
  1. //name reduction
  2. //codechef may
  3.  
  4.  
  5. #include<iostream>
  6. #include<cstring>
  7. #define limit 41000
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. int flag=0;
  14. char a[limit],b[limit],c[limit];
  15. int t,n;
  16. cin>>t;
  17.  
  18. for(int be=0;be<t;be++)
  19. {
  20.  
  21.  
  22.  
  23. cin>>a>>b;
  24. cin.ignore();
  25. cin>>n;
  26. cin.ignore();
  27.  
  28. long al[26]={0};
  29.  
  30. for(int i=0;i<n;i++)
  31. {
  32. cin>>c;
  33. // tolower(c);
  34. cin.ignore();
  35.  
  36. for(int j=0;j<strlen(c);j++)
  37. {
  38.  
  39. al[(int)c[j]-97]++;
  40. //cout<<(int)c[j]-97;
  41. }
  42.  
  43.  
  44. }//all letters stored in al
  45.  
  46.  
  47. for(int m=0;m<strlen(a);m++)
  48. {
  49. al[(int)a[m]-97]--;
  50. }
  51.  
  52.  
  53.  
  54. for(int n=0;n<strlen(b);n++)
  55. {
  56. al[(int)b[n]-97]--;
  57. }
  58.  
  59.  
  60. for(int p=0;p<26;p++)
  61. if(al[p]>0)
  62. {
  63. flag=1;
  64. break;
  65. }
  66.  
  67. if(flag==1)
  68. cout<<"NO"<<endl;
  69. else
  70. cout<<"YES"<<endl;
  71.  
  72.  
  73. }
  74. }
Success #stdin #stdout 0s 2896KB
stdin
3
tom marvoloriddle
2
lord
voldemort
cheap up
1
heapcup
bruce wayne
2
bat
man
stdout
YES
YES
NO