题目大意:给你两串字符串,判断第二串是不是第一串经过加密处理的。加密方式为,替换和排列

解题思路:因为他想怎么替换就怎么替换,也可以不替换。所以枚举会爆炸,然后就变成了只要判断不同字母出现的个数,是否一致。然后所以就。。。两个级数数组,计算完再排序,比较。。。

ac代码:

#include <iostream>  
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
char a[1005], b[1005];
int len, cnt1[26], jud, cnt2[26];
while (scanf("%s%s", a, b)!=EOF){
len = strlen(a);
jud = 1;
memset(cnt1, 0, sizeof(cnt1));
memset(cnt2, 0, sizeof(cnt2));
for (int i=0; i<len; i++){
cnt1[a[i]-'A']++;
cnt2[b[i]-'A']++;
}
sort(cnt1, cnt1+26);
sort(cnt2, cnt2+26);
for (int i=0; i<26; i++)
if (cnt1[i] != cnt2[i])
jud = 0;
if (jud)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}