rt,只得了70分,请教各位神犇,谢谢。

#include<bits/stdc++.h>
using namespace std;
vector<string> s;
string str;
map<string, bool> mp;
string change(string& word){
if(word.size() <= 2){
return word;
}
string mid = word.substr(1, word.size() - 2);
sort(mid.begin(), mid.end());
return word.front() + mid + word.back();
}
bool check(){
string y = change(str);
if(mp[y] == 1) return 1;
return 0;
}
int main(){
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++){
string str;
cin >> str;
s.push_back(str);
}
for(auto& word : s){
string str = change(word);
mp[str] = 1;
}
for(int i = 1; i <= m; i ++){
cin >> str;
if(check()) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
思路:将会的单词内部排序,与不会的单词作比较。
求助,谢谢。