Advertisement
Rofyda_Elghadban1

Untitled

Aug 31st, 2023
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.83 KB | None | 0 0
  1.  /*Rofyda Mohamed Hamed Hamed Elghadban*/
  2.  //#include <bits/stdc++.h>
  3.  #include <iostream>
  4.  #include <iomanip>
  5.  #include <cmath>
  6.  #include <algorithm>
  7.  #include <cstdlib>
  8.  #include <limits.h>
  9.  #include <string>
  10.  #include <vector>
  11.  #include <map>
  12.  #include <stack>
  13.  #include <set>
  14.  #include <deque>
  15.  #include <fstream>
  16.  #include <bitset>
  17.  #include <cmath>
  18.  #include <numeric>
  19.  #include <cstring>
  20.  #include <utility>
  21.  #include <queue>
  22.  
  23.  /***********************************************************************************/
  24.  
  25.  #define ll long long
  26.  #define ull unsigned long long
  27.  #define pi 3.141592654
  28.  #define NUM 1e18
  29.  #define Mod  1'000'000'007
  30.  #define fixed(n) fixed<<setprecision(n)
  31.  #define cin(v) for(auto &i:v) cin >> i ;
  32.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  33.  #define Ceil(a,b) ((a/b)+(a%b ? 1 : 0))
  34.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  35.  #define small(x) (x>=97&&x<=122)
  36.  #define capital(x) (x>=65&&x<=90)
  37.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  38.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  39.  #define all(v) ((v).begin()), ((v).end())
  40.  #define allr(v) ((v).rbegin()), ((v).rend())
  41.  #define updmax(a,b) a=max(a,b)
  42.  #define updmin(a,b) a=min(a,b)
  43.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  44.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  45.  
  46.  /***********************************************************************************/
  47.  
  48.  using namespace std;
  49.  
  50.  void Rofyda_Elghadban(){
  51.   #ifndef ONLINE_JUDGE  
  52.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  53.    #endif
  54.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  55.  }
  56.  
  57.  void solve(){
  58.   string s,t,p;
  59.   cin>>s>>t>>p;
  60.   int freq[27]{},i=0,j=0;
  61.   for(int i=0;i<p.size();i++){
  62.     freq[p[i]-'a']++;
  63.   }
  64.   while(i<s.size()&&j<t.size()){
  65.     if(s[i]==t[j]){
  66.       i++;
  67.       j++;
  68.     }else{
  69.       if(freq[t[j]-'a']>0){
  70.         freq[t[j]-'a']--;
  71.         j++;
  72.       }else{
  73.         cout<<"NO"<<"\n";
  74.         return ;
  75.       }
  76.     }
  77.   }
  78.   if(i<s.size()){
  79.     cout<<"NO"<<"\n";
  80.     return ;
  81.   }
  82.   for(int k=j;k<t.size();k++){
  83.     if(freq[t[k]-'a']>0){
  84.       freq[t[k]-'a']--;
  85.     }else{
  86.       cout<<"NO"<<"\n";
  87.       return ;
  88.     }
  89.   }cout<<"YES"<<"\n";
  90.  }
  91.  
  92.  int main(){
  93.   Rofyda_Elghadban();
  94.  //freopen("input.txt","r",stdin);
  95.  //freopen("output.txt","r",stdout);
  96.  
  97.  //solve();
  98.  
  99. //  int t;
  100. //  cin>>t;
  101. //  while(t--){
  102. //   string s,t,p;
  103. //   cin>>s>>t>>p;
  104. //   if(s.size()==t.size()){
  105. //     if(s==t){
  106. //       cout<<"YES"<<"\n";
  107. //     }else{
  108. //       cout<<"NO"<<"\n";
  109. //     }
  110. //   }else{
  111. //     for(int i=0;i<t.size();i++){
  112. //       if(t[i]==s[i]){
  113. //         continue;
  114. //       }else{
  115. //         for(int j=0;j<p.size();j++){
  116. //           if(p[j]==t[i]){
  117. //             s+=p[j];
  118. //           }
  119. //         }
  120. //       }
  121. //     }
  122. //   }cout<<s<<"\n";
  123. //  }
  124.  int t;
  125.  cin>>t;
  126.  while(t--){
  127.   solve();
  128.  }
  129.  
  130.  
  131.  
  132.  return 0;
  133. }
  134.  
  135.  
  136. /*
  137.  
  138. * * * * * * * *    * * * * * * * *    * * * * * * * *    *             *
  139. *             *    *             *    *                  *             *
  140. *             *    *             *    *                  *             *
  141. *             *    *             *    *                  *             *
  142. * * * * * * * *    *             *    * * * * * * * *    * * * * * * * *
  143. * *                *             *    *                                *
  144. *   *              *             *    *                                *
  145. *     *            *             *    *                                *
  146. *       *          *             *    *                                *
  147. *         *        *             *    *                                *
  148. *           *      *             *    *                                *    
  149. *             *    * * * * * * * *    *                  * * * * * * * *
  150.  
  151. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement