51nod
题目链接
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
int n, k;
string s;
cin >> n;
unordered_map<string, vector<string>> mp;
for(int i = 0; i < n; i++){
cin >> s;
string str = s;
sort(s.begin(), s.end());
mp[s].push_back(str);
}
cin >> k;
while(k--){
cin >> s;
string str = s;
sort(s.begin(), s.end());
int t = mp.count(s);
if(t == 0) cout<<0<<endl;
else{
int u = 0;
for(auto v : mp[s]) if(v == str) u++;
cout<< mp[s].size() - u <<endl;
}
}
return 0;
}