-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpat_basic_1039.cpp
65 lines (62 loc) · 1.14 KB
/
pat_basic_1039.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
#include <stdio.h>
#include<iostream>
#include<string>
#define M 100
using namespace std;
int main(){
string in1, in2;
int count[M] = { 0 };
int yescount = 0, nocount = 0;
cin >> in1 >> in2;
int size1 = in1.size();
int size2 = in2.size();
for (int i = 0; i < size1; i++)
{
if (in1[i] >= '0'&&in1[i] <= '9'){
count[in1[i] - '0'] += 1;
}
else if (in1[i] >= 'a'&&in1[i] <= 'z'){
count[in1[i] - 'a' + 10] += 1;
}
else if (in1[i] >= 'A'&&in1[i] <= 'Z'){
count[in1[i] - 'A' + 36] += 1;
}
}
for (int j = 0; j < size2; j++)
{
if (in2[j] >= '0'&&in2[j] <= '9'){
if (count[in2[j] - '0']>0){
count[in2[j] - '0'] -= 1;
yescount += 1;
}
else{
nocount += 1;
}
}
else if (in2[j] >= 'a'&&in2[j] <= 'z'){
if (count[in2[j] - 'a'+10] > 0){
count[in2[j] - 'a'+10] -= 1;
yescount += 1;
}
else{
nocount += 1;
}
}
else if (in2[j] >= 'A'&&in2[j] <= 'Z'){
if (count[in2[j] - 'A' + 36] > 0){
count[in2[j] - 'A' + 36] -= 1;
yescount += 1;
}
else{
nocount += 1;
}
}
}
if (nocount == 0){
cout << "Yes " << size1 - yescount;
}
else{
cout << "No " << nocount;
}
return 0;
}