fork(1) download
  1. #include<stdio.h>
  2. #include<string.h>
  3. char ip[1009][1009],input[1009];
  4. int hash[1009][26];
  5. int main()
  6. {
  7. int test,n;
  8. scanf("%d",&test);
  9. while(test--)
  10. {
  11. scanf("%d",&n);
  12. for(int i=0;i<n;i++)
  13. {
  14. for(int j=0;j<26;j++)
  15. hash[i][j]=0;
  16. }
  17. for(int i=0;i<n;i++)
  18. {
  19. scanf("%s",ip[i]);
  20. int len=strlen(ip[i]);
  21. for(int j=0;j<len;j++)
  22. {
  23. hash[i][ip[i][j]-'a']++;
  24. }
  25. }
  26. scanf("%s",input);
  27. int len=strlen(input);
  28. for(int i=0;i<n;i++)
  29. {
  30. int found=1;
  31. for(int j=0;j<len;j++)
  32. {
  33. if(hash[i][input[j]-'a']==0)
  34. {
  35. found=0;
  36. break;
  37. }
  38. }
  39. if(found)
  40. printf("%s ",ip[i]);
  41. }
  42. printf("\b\n");
  43.  
  44. }
  45. return 0;
  46. }
Runtime error #stdin #stdout 0s 4236KB
stdin
Standard input is empty
stdout
Standard output is empty