Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Rofyda Mohamed Hamed Hamed Elghadban*/
- //#include <bits/stdc++.h>
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <algorithm>
- #include <cstdlib>
- #include <limits.h>
- #include <string>
- #include <vector>
- #include <map>
- #include <stack>
- #include <set>
- #include <deque>
- #include <fstream>
- #include <bitset>
- #include <cmath>
- #include <numeric>
- #include <cstring>
- #include <utility>
- #include <queue>
- /***********************************************************************************/
- #define ll long long
- #define ull unsigned long long
- #define pi 3.141592654
- #define NUM 1e18
- #define Mod 1'000'000'007
- #define fixed(n) fixed<<setprecision(n)
- #define cin(v) for(auto &i:v) cin >> i ;
- #define cout(v) for(auto &i:v) cout << i <<" ";
- #define Ceil(a,b) ((a/b)+(a%b ? 1 : 0))
- #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
- #define small(x) (x>=97&&x<=122)
- #define capital(x) (x>=65&&x<=90)
- #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
- #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
- #define all(v) ((v).begin()), ((v).end())
- #define allr(v) ((v).rbegin()), ((v).rend())
- #define updmax(a,b) a=max(a,b)
- #define updmin(a,b) a=min(a,b)
- #define ceil(a,b) ((a/b)+(a%b?1:0))
- /* asc -> 1 2 3 ,des -> 3 2 1 */
- /***********************************************************************************/
- using namespace std;
- void Rofyda_Elghadban(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- }
- void solve(){
- string s,t,p;
- cin>>s>>t>>p;
- int freq[27]{},i=0,j=0;
- for(int i=0;i<p.size();i++){
- freq[p[i]-'a']++;
- }
- while(i<s.size()&&j<t.size()){
- if(s[i]==t[j]){
- i++;
- j++;
- }else{
- if(freq[t[j]-'a']>0){
- freq[t[j]-'a']--;
- j++;
- }else{
- cout<<"NO"<<"\n";
- return ;
- }
- }
- }
- if(i<s.size()){
- cout<<"NO"<<"\n";
- return ;
- }
- for(int k=j;k<t.size();k++){
- if(freq[t[k]-'a']>0){
- freq[t[k]-'a']--;
- }else{
- cout<<"NO"<<"\n";
- return ;
- }
- }cout<<"YES"<<"\n";
- }
- int main(){
- Rofyda_Elghadban();
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","r",stdout);
- //solve();
- // int t;
- // cin>>t;
- // while(t--){
- // string s,t,p;
- // cin>>s>>t>>p;
- // if(s.size()==t.size()){
- // if(s==t){
- // cout<<"YES"<<"\n";
- // }else{
- // cout<<"NO"<<"\n";
- // }
- // }else{
- // for(int i=0;i<t.size();i++){
- // if(t[i]==s[i]){
- // continue;
- // }else{
- // for(int j=0;j<p.size();j++){
- // if(p[j]==t[i]){
- // s+=p[j];
- // }
- // }
- // }
- // }
- // }cout<<s<<"\n";
- // }
- int t;
- cin>>t;
- while(t--){
- solve();
- }
- return 0;
- }
- /*
- * * * * * * * * * * * * * * * * * * * * * * * * * *
- * * * * * * *
- * * * * * * *
- * * * * * * *
- * * * * * * * * * * * * * * * * * * * * * * * * * *
- * * * * * *
- * * * * * *
- * * * * * *
- * * * * * *
- * * * * * *
- * * * * * *
- * * * * * * * * * * * * * * * * * * *
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement