-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_uva156.cpp
50 lines (48 loc) · 927 Bytes
/
map_uva156.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
map<string, int> cnt;
vector<string> words;
string repr(const string& s)
{
string ans = s;
for(int i = 0; i < ans.length(); i++)
{
ans[i] = tolower(ans[i]);
}
sort(ans.begin(), ans.end());
return ans;
}
int main()
{
string s;
while (cin >> s)
{
if (s[0] == '#')
break;
words.push_back(s);
string r = repr(s);
if (!cnt.count(r))
cnt[r] = 0;
cnt[r]++;
}
vector<string> ans;
for (int i = 0; i < words.size(); i++)
{
if (cnt[repr(words[i])] == 1)
{
ans.push_back(words[i]);
}
}
sort(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++)
{
cout << ans[i] << '\n';
}
system("pause");
return 0;
}