Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define pb push_back
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- int n;
- cin >> n;
- string arr[n];
- for(int i = 0; i < n; i++){
- cin >> arr[i];
- map<char, char> m;
- char last = 'a';
- for(int j = 0; j < arr[i].length(); j++){
- if(m.find(arr[i][j]) == m.end()){
- arr[i][j] = last;
- m[arr[i][j]] = last;
- last++;
- }
- else{
- arr[i][j] = m[arr[i][j]];
- }
- }
- }
- sort(arr, arr+n);
- ll tot = 0, re = 1;
- for(int i = 1; i < n; i++){
- cout << arr[i] << endl;
- if(arr[i] == arr[i-1]){ re++;}
- else {
- tot += ((re * (re-1))/2);
- re = 1;
- }
- }
- cout << tot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement