#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
string word, tmp;
map<string, set<string> > dicMap;
#ifndef ONLINE_JUDGE
ifstream cin("d:\\OJ\\uva_in.txt");
#endif
while (cin >> word) {
if (word == "XXXXXX")
break;
tmp = word;
sort(tmp.begin(), tmp.end());
dicMap[tmp].insert(word);
}
while (cin >> word) {
if (word == "XXXXXX") break;
sort(word.begin(), word.end());
if (dicMap.count(word)) {
set<string> wordSet = dicMap[word];
for (set<string>::const_iterator it = wordSet.begin();
it != wordSet.end(); it++) {
cout << *it << endl;
}
} else {
cout << "NOT A VALID WORD" << endl;
}
cout << "******" << endl;
}
return 0;
}
UVa642 - Word Amalgamation
最新推荐文章于 2019-11-17 20:21:28 发布