Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define int long long
- using namespace std;
- unordered_set<string> se;
- string a[2000];
- signed main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int n, k;
- cin >> n >> k;
- for(int i=0;i<n;i++) {
- cin >> a[i];
- se.insert(a[i]);
- }
- int ans = 0;
- for(int i=0;i<n;i++) {
- for(int j=0;j<n;j++) {
- string tmp = "";
- if(i == j) continue;
- for(int x=0;x<k;x++) {
- if(a[i][x] == a[j][x]) tmp += a[i][x];
- else {
- int alph = 'S' + 'E' + 'T';
- char p = alph - a[j][x] - a[i][x];
- tmp += p;
- }
- }
- if(se.count(tmp)) ans++;
- }
- }
- cout << ans / 6 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement