#include<iostream> #include<map> #include<vector> #include<algorithm> #include<string> using namespace std; struct word{ vector<string> s; }words[30008]; //vector<string> v; map<string ,int> mp; bool cmp(word a,word b) { if(a.s.size()==b.s.size()) return a.s[0] < b.s[0]; return a.s.size()>b.s.size(); } int main() { char str[30]; string s1,s2; int sum=0; while(scanf("%s",str)!=EOF) { s1=str; sort(str,str+strlen(str)); s2=str; if(mp.find(s2)!=mp.end()) { words[mp[s2]].s.push_back(s1); }else { mp[s2]=sum++; vector<string> v; v.push_back(s1); words[mp[s2]].s=v; } } for(int i=0;i<sum;i++) { //words one=v[i]; sort(words[i].s.begin(),words[i].s.end()); } sort(words,words+sum,cmp); //cout<<sum<<endl; for(int i=0;i<5; i++) { if(i>=sum) { printf("Group of size 0: ./n"); continue; } word one =words[i]; int len=one.s.size(); printf("Group of size %d:",len); for(int j=0;j<len; j++) { cout<<" "<<one.s[j]; while(j+1<len&&one.s[j]==one.s[j+1])j++; //cout<<"fds"<<endl; } printf(" ./n"); } //system("pause"); return 0; }