题目传送门:https://www.luogu.com.cn/problem/P1808
非常有技巧的一个题,先试用sort函数将输入的字符串排序,然后把排序后的字符串放入set集合中(借用set集合的去重),最后set中元素的个数就是答案。
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<string> words;
int main(){
int t;
string temp;
cin>>t;
while(t--){
cin>>temp;
sort(temp.begin(),temp.end());
words.insert(temp);
}
cout<<words.size()<<endl;
return 0;
}