Submission #1279507

#TimeUsernameProblemLanguageResultExecution timeMemory
1279507okahak71Set (COCI21_set)C++20
40 / 110
1095 ms55920 KiB
#include <bits/stdc++.h>
#define ll long long
#define vec vector
#define pb push_back
#define pll pair<ll, ll>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
using namespace std;

const ll inf = 3e5 + 5;

void _(){
    ll k, n, ans = 0; cin >> n >> k;
    unordered_map<string, bool>mp;
    vec<string>a(n); for(string &s : a) {cin >> s; mp[s] = 1;}
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < i; j++){
            string third = "";
            for(ll kk = 0; kk < k; kk++){
                if(a[i][kk] == a[j][kk]) third += a[i][kk];
                else{
                    set<char>st = {'1', '2', '3'};
                    st.erase(a[i][kk]), st.erase(a[j][kk]);
                    third += *st.begin();
                }
            }
            //cout << third << ' ' << i << ' ' << j << endl;
            ans += mp[third];
        }
    } cout << ans / 3ll << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t = 1;
    while(t--) _();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...