链接:http://codeforces.com/contest/975/problem/A
题意:在输入n个单词以后,输出root的数量。root的意思是字符串中不重复的字母,跟顺序无关。比如amer跟arem是一个root。它们排序后都是aemr
用stl来写这道题会比较方便
但是因为stl用的不熟练,导致没写出来,又掉分了
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 6 7 map<string,int> m; 8 set<char> se; 9 int main() 10 { 11 ios 12 int n,ans = 0; 13 cin >> n; 14 string s,t; 15 while(n--) 16 { 17 cin >> s; 18 t.clear(); 19 se.clear(); 20 for(int j = 0;j < s.size();j++) 21 se.insert(s[j]); 22 set<char>::iterator it; 23 for(it = se.begin();it != se.end();it++) 24 t += *it; 25 if(!m[t]) 26 ans++; 27 m[t] = 1; 28 } 29 printf("%d ",ans); 30 return 0; 31 }