UVa-156 Ananagrams(map映射)

 #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include<cstdlib>
#include<cstring>
#include <vector>
#include <queue>
#include <map>
#include <sstream> using namespace std;
#define maxn 100100
map<string, int>ma;
std::vector<string> words;
string func(string str) {
string ans = str;
for (int i = ; i < ans.length(); i++) {
ans[i] = tolower(ans[i]);
} sort(ans.begin(), ans.end());
return ans;
}
int main() {
std::ios::sync_with_stdio(false);
string str;
while (cin >> str) {
if (str[] == '#') {
break;
}
words.push_back(str);
string r = func(str);
if (!ma.count(r)) {
ma[r] = ;
}
ma[r]++;
}
std::vector<string> ans;
for (int i = ; i < words.size(); i++) {
if (ma[func(words[i])] == ) {
ans.push_back(words[i]);
}
sort(ans.begin(), ans.end()); }
for (int i = ; i < ans.size(); i++) {
cout << ans[i] << endl;
}
return ;
}
上一篇:BZOJ(7) 1085: [SCOI2005]骑士精神


下一篇:A*算法详解 BZOJ 1085骑士精神