-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob1.cpp
69 lines (60 loc) · 1.16 KB
/
prob1.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
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <stdlib.h>
using namespace std;
vector<int> getCountOfAlphabets(string str, int n){
vector<int> count(26,0);
for(int i = 0; i<n; i++){
char ch = str[i];
if(ch == ' ') continue;
count[ch-'a']++;
}
return count;
}
string getInput(){
cin.clear();
string z,s;
while (true)
{
cin>>z;
s+=z;
if(cin.peek()=='\n')
break;
}
return s;
}
bool solve(){
string str1, str2;
str1 = getInput();
str2 = getInput();
// getline(cin,str2);
// cout<<str1.size();
// cout<<str2.size();
int n1 = str1.size(), n2 = str2.size();
vector<int> count1(26);
count1 = getCountOfAlphabets(str1,n1);
vector<int> count2(26);
count2 = getCountOfAlphabets(str2,n2);
for(int i = 0; i<26; i++){
// cout<<"count1[i]"<<count1[i]<<endl;
// cout<<"count2[i]"<<count2[i]<<endl;
if(count1[i] < count2[i])
return false;
}
return true;
}
int main(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int t; cin>>t;
for(int i = 0; i<=t; i++){
if(solve())
cout << "Possible\n";
else
cout << "Not Possible\n";
t--;
}
return 0;
}