-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lapindromes - LAPIN.cpp
50 lines (48 loc) · 1.26 KB
/
Lapindromes - LAPIN.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
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
int n;
cin >> n;
string a;
while (n--) {
cin >> a;
map<char, int> a1;
map<char, int> a2;
map<char, int> :: iterator it1;
map<char, int> :: iterator it2;
if ((a.size() % 2) == 0) {
for (int i = 0; i < a.size() / 2; i++) {
a1[a[i]]++;
}
for (int i = a.size() / 2; i < a.size(); i++) {
a2[a[i]]++;
}
}
else {
for (int i = 0; i < a.size() / 2; i++) {
a1[a[i]]++;
}
for (int i = (a.size() / 2) + 1; i < a.size(); i++) {
a2[a[i]]++;
}
}
int flag = 1;
for (it1 = a1.begin(), it2 = a2.begin(); it1 != a1.end(), it2 != a2.end(); it1++, it2++) {
if (((it1 -> first) == (it2 -> first)) && ((it1 -> second) == (it2 -> second))) {
continue;
}
else {
flag = 0;
cout << "NO" << endl;
break;
}
}
if (flag) {
cout << "YES" << endl;
}
}
return 0;
}