Skip to content

Instantly share code, notes, and snippets.

@enzerr
Created April 6, 2023 11:04
Show Gist options
  • Save enzerr/24ccd19117b623d3d0120ccf0300243a to your computer and use it in GitHub Desktop.
Save enzerr/24ccd19117b623d3d0120ccf0300243a to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<string, int> mp;
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
for(int i = 0; i < n; i++){
string s; cin >> s;
map<char, int> freq;
for(char x : s) freq[x]++;
string aux;
for(auto[k, v] : freq) aux.push_back(v);
sort(aux.begin(), aux.end());
mp[aux]++;
}
int ans = 0;
for(auto[k, v] : mp){
ans += (v*v-v)/2;
}
cout << ans << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment