-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecnuoj3238.cpp
49 lines (48 loc) · 978 Bytes
/
ecnuoj3238.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
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
bool cmp(string a,string b)
{
set<char> sa;
set<char> sb;
for(string::iterator ia=a.begin();ia!=a.end();ia++)
{
sa.insert(*ia);
}
for(string::iterator ib=b.begin();ib!=b.end();ib++)
{
sb.insert(*ib);
}
if(sa.size()!=sb.size())
{
return sa.size()>sb.size();
}
return a<b;
}
int main()
{
int k=0;
scanf("%d",&k);
for (size_t i = 0; i < k; i++)
{
int t=0;
scanf("%d",&t);
vector<string> v;
for(size_t j=0;j<t;j++)
{
string s;
cin>>s;
v.push_back(s);
}
sort(v.begin(),v.end(),cmp);
cout<<"case #"<<i<<":"<<endl;
for (size_t i = 0; i < v.size(); i++)
{
cout<<v[i]<<endl;
}
}
return 0;
}