Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define pb push_back
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.     ios_base::sync_with_stdio(0);
  9.     cin.tie(NULL);
  10.  
  11.     int n;
  12.     cin >> n;
  13.     string arr[n];
  14.     for(int i = 0; i < n; i++){
  15.         cin >> arr[i];
  16.         map<char, char> m;
  17.         char last = 'a';
  18.         for(int j = 0; j < arr[i].length(); j++){
  19.             if(m.find(arr[i][j]) == m.end()){
  20.                 arr[i][j] = last;
  21.                 m[arr[i][j]] = last;
  22.                 last++;
  23.             }
  24.             else{
  25.                 arr[i][j] = m[arr[i][j]];
  26.                 }
  27.         }
  28.     }
  29.         sort(arr, arr+n);
  30.         ll tot = 0, re = 1;
  31.         for(int i = 1; i < n; i++){
  32.             cout << arr[i] << endl;
  33.             if(arr[i] == arr[i-1]){ re++;}
  34.             else {
  35.                 tot += ((re * (re-1))/2);
  36.                 re = 1;
  37.             }
  38.         }
  39.         cout << tot;
  40.  
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement