-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path559B.cpp
More file actions
46 lines (45 loc) · 1.23 KB
/
559B.cpp
File metadata and controls
46 lines (45 loc) · 1.23 KB
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
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1 , s2;
cin>>s1;
cin>>s2;
unordered_map<char , int>checker1;
unordered_map<char , int>checker2;
unordered_map<char , int>checker11;
unordered_map<char , int>checker12;
unordered_map<char , int>checker21;
unordered_map<char , int>checker22;
int n = checker1.size();
int divided = n / 2;
for(auto &c : s1){
checker1[c]++;
}
for(auto &c : s2){
checker2[c]++;
}
//Now we must divide the 2 hashmaps into 4 hashmaps!!
int n1 = (int)checker1.size();
int half1 = n1 / 2;
int count = 0;
for (auto &p : checker1) {
if (count < half1) checker11[p.first] = p.second;
else checker12[p.first] = p.second;
++count;
}
int n2 = (int)checker2.size();
int half2 = n2 / 2;
int count = 0;
for(auto &p : checker2){
if(count < half2){
checker21[p.first] = p.second;
}
else{
checker22[p.first] = p.second;
count++;
}
}
}
if((checker11 == checker21 && checker12 == checker22) || (checker11 == checker22 && checker12 == checker21)){
cout<<"YES";
}