原题链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1095
思路:排序存储到map里面,另外主要判断当前要查询的单词是否有一个原单词与它相同,如果有就减去
AC代码:
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1000000;
int main() {
int n, q;
scanf("%d", &n);
char str[14];
map<string, int> m1, m2;
for (int i = 0; i < n; i++) {
scanf("%s", str);
m1[str]++;
sort(str, str + strlen(str));
m2[str]++;
}
scanf("%d", &q);
while (q--) {
scanf("%s", str);
int num1 = m1[str];
sort(str, str + strlen(str));
int num2 = m2[str];
printf("%d\n", num2 - num1);
}
return 0;
}