Advertisement
pdpd123

Problem 2

Feb 17th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4.  
  5. unordered_set<string> se;
  6. string a[2000];
  7.  
  8. signed main() {
  9.     ios_base::sync_with_stdio(0);
  10.     cin.tie(0);
  11.     int n, k;
  12.     cin >> n >> k;
  13.     for(int i=0;i<n;i++) {
  14.         cin >> a[i];
  15.         se.insert(a[i]);
  16.     }
  17.     int ans = 0;
  18.     for(int i=0;i<n;i++) {
  19.         for(int j=0;j<n;j++) {
  20.             string tmp = "";
  21.             if(i == j) continue;
  22.             for(int x=0;x<k;x++) {
  23.                 if(a[i][x] == a[j][x]) tmp += a[i][x];
  24.                 else {
  25.                     int alph = 'S' + 'E' + 'T';
  26.                     char p = alph - a[j][x] - a[i][x];
  27.                     tmp += p;
  28.                 }
  29.             }
  30.             if(se.count(tmp)) ans++;
  31.         }
  32.     }
  33.     cout << ans / 6 << endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement