![UVa1339 Ancient Cipher UVa1339 Ancient Cipher](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
#include <iostream>
#include <string>
#include <cstring> // for memset
#include <algorithm>
using namespace std;
int main()
{
int ce[26], co[26];
string encrypted, orginal;
string::size_type i, len;
ios::sync_with_stdio(false);
while (cin >> encrypted >> orginal)
{
memset(ce, 0, sizeof(ce));
memset(co, 0, sizeof(co));
len = orginal.length();
for (i = 0; i < len; ++i)
{
++ce[encrypted[i]-'A'];
++co[orginal[i]-'A'];
}
sort(ce, ce+26);
sort(co, co+26);
if (equal(ce, ce+26, co))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}