Submission #1172083

#TimeUsernameProblemLanguageResultExecution timeMemory
1172083nguyenkhangninh99PIN (CEOI10_pin)C++17
100 / 100
204 ms10636 KiB

#include <bits/stdc++.h>
using namespace std;

#define int long long

map<string, int> mp[16];
int f[4];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;

    for(int i = 0; i < n; i++){
        string x; cin >> x;
        for(int mask = 1; mask < (1 << 4) - 1; mask++){
            string t = "";
            for(int j = 0; j < 4; j++) if(mask & (1 << j)) t += x[j];
            f[3 - __builtin_popcount(mask)] += mp[mask][t]++;
        }
    }
    
    if(k == 1) cout << f[0];
    if(k == 2) cout << f[1] - (f[0] * 3);
    if(k == 3) cout << f[2] - (f[1] * 2 - f[0] * 3);
    if(k == 4) cout << n * (n - 1) / 2 - (f[0] - f[1] + f[2]);
 }
#Verdict Execution timeMemoryGrader output
Fetching results...