// UVa 1339 - Ancient Cipher #include <string> #include <string.h> #include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { string sa, sb; while (cin >> sa >> sb) { int ca['Z' + 1], cb['Z' + 1]; memset(ca, 0, sizeof(ca)); for (int i = sa.length() - 1; i >= 0; i--) ca[sa[i]]++; memset(cb, 0, sizeof(cb)); for (int i = sb.length() - 1; i >= 0; i--) cb[sb[i]]++; int a[26], b[26]; for (char ch = 'A'; ch <= 'Z'; ch++) { a[ch - 'A'] = ca[ch]; b[ch - 'A'] = cb[ch]; } sort(a, a + 26); sort(b, b + 26); bool good = true; for (int i = 0; i < 26 && good; i++) good = a[i] == b[i]; if (good) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
Monday, May 4, 2015
UVa 1339 - Ancient Cipher
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment