Advertisement
IQOverload

CF1000247B

Aug 14th, 2014
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <algorithm>
  2. #include <bitset>
  3. #include <deque>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <iostream>
  9. #include <list>
  10. #include <map>
  11. #include <queue>
  12. #include <set>
  13. #include <sstream>
  14. #include <stack>
  15. #include <string>
  16. #include <utility>
  17. #include <vector>
  18.  
  19. #define fst first
  20. #define snd second
  21. #define all(x) (x).begin(), (x).end()
  22. #define clr(a, v) memset(a, v, sizeof(a))
  23. #define pb push_back
  24. #define mp make_pair
  25. #define sz(x) (int)(x.size())
  26. #define FORN(i,s,n) for(int i=s;i<(int)(n);i++)
  27. #define FOR(i,n) FORN(i,0,n)
  28. #define FORIT(i,x) for( typeof x.begin() i=x.begin(); i!=x.end(); i++ )
  29. #define trace(x) cerr << #x << ": " << x << endl;
  30. #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
  31.  
  32. using namespace std;
  33.  
  34. typedef long long int64;
  35. typedef vector <int> vi;
  36. typedef pair <int,int> ii;
  37. typedef vector <string> vs;
  38. typedef vector <ii> vii;
  39.  
  40. const int INF = 2e9+9;
  41.  
  42. int main(){
  43. int N; cin>>N;
  44. string s;
  45. int a[30],cont;
  46. map <string, int> m;
  47. FOR(i,N){
  48. cont=0;
  49. cin>>s;
  50. clr(a,0);
  51. string aux="";
  52. FOR(j,sz(s)){
  53. if ( a[s[j]-'a']==0) a[s[j]-'a']=++cont;
  54. aux+=('a'-1+a[s[j]-'a']);
  55. }
  56. m[aux]++;
  57. }
  58. int64 ans=0;
  59. for( map<string,int>::iterator it=m.begin();it!=m.end();it++ ){
  60. ans+=(int64(it->snd)*int64(it->snd - 1))/2;
  61. }
  62. cout<<ans<<endl;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement