Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <deque>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <list>
- #include <map>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- #define fst first
- #define snd second
- #define all(x) (x).begin(), (x).end()
- #define clr(a, v) memset(a, v, sizeof(a))
- #define pb push_back
- #define mp make_pair
- #define sz(x) (int)(x.size())
- #define FORN(i,s,n) for(int i=s;i<(int)(n);i++)
- #define FOR(i,n) FORN(i,0,n)
- #define FORIT(i,x) for( typeof x.begin() i=x.begin(); i!=x.end(); i++ )
- #define trace(x) cerr << #x << ": " << x << endl;
- #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
- using namespace std;
- typedef long long int64;
- typedef vector <int> vi;
- typedef pair <int,int> ii;
- typedef vector <string> vs;
- typedef vector <ii> vii;
- const int INF = 2e9+9;
- int main(){
- int N; cin>>N;
- string s;
- int a[30],cont;
- map <string, int> m;
- FOR(i,N){
- cont=0;
- cin>>s;
- clr(a,0);
- string aux="";
- FOR(j,sz(s)){
- if ( a[s[j]-'a']==0) a[s[j]-'a']=++cont;
- aux+=('a'-1+a[s[j]-'a']);
- }
- m[aux]++;
- }
- int64 ans=0;
- for( map<string,int>::iterator it=m.begin();it!=m.end();it++ ){
- ans+=(int64(it->snd)*int64(it->snd - 1))/2;
- }
- cout<<ans<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement