Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <utility>
  5. #include <map>
  6. #include <vector>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. int t;
  14. cin>>t;
  15.  
  16. while (t--)
  17. {
  18. string s,t,p;
  19. cin>>s>>t>>p;
  20.  
  21. int j = 0;
  22. int i = 0;
  23. bool flag = true;
  24. for (i=0;i<s.size();i++)
  25. {
  26. while ( s[i] != t[j] && j < t.size() ) j++;
  27.  
  28. if ( j == t.size() )
  29. {
  30. flag = false;
  31. break;
  32. }
  33. else if ( j == t.size() && i < s.size() )
  34. {
  35. flag = false;
  36. break;
  37. }
  38.  
  39. j++;
  40. }
  41.  
  42. if ( flag )
  43. {
  44. int niz[30] = {};
  45. for (int i=0;i<s.size();i++)
  46. niz[s[i]-'a']++;
  47. for (int i=0;i<p.size();i++)
  48. niz[p[i]-'a']++;
  49. for (int i=0;i<t.size();i++)
  50. niz[t[i]-'a']--;
  51.  
  52. for (int i='a';i<='z';i++)
  53. if ( niz[i-'a'] < 0 )
  54. {
  55. flag = false;
  56. break;
  57. }
  58.  
  59. if ( flag ) cout<<"YES"<<endl;
  60. else cout<<"NO"<<endl;
  61. }
  62. else
  63. {
  64. cout<<"NO"<<endl;
  65. }
  66. }
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement