-
Notifications
You must be signed in to change notification settings - Fork 0
/
NAME1.cpp
58 lines (48 loc) · 1.01 KB
/
NAME1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <unordered_map>
#include <cstring>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
string a,b;
cin>>a>>b;
//map1 for parent's characters
//map2 for childrend's characters
unordered_map<char,int> map1;
unordered_map<char,int> map2;
//storing the frequency of parent characters into map1
for(int i=0;i<a.length();i++)
map1[a[i]]++;
for(int i=0;i<b.length();i++)
map1[b[i]]++;
int child;
cin>>child;
while(child--)
{
string temp;
cin>>temp;
for(int i=0;i<temp.length();i++)
map2[temp[i]]++;
}
//checking is child substring of a parent of not
bool flag=1;
for(auto it:map2)
{
if(map1[it.first]>=it.second)
continue;
else
{
flag=0;
break;
}
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}