Submission #721985

# Submission time Handle Problem Language Result Execution time Memory
721985 2023-04-11T09:51:20 Z Dec0Dedd PIN (CEOI10_pin) C++14
70 / 100
271 ms 14776 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int K = 4;
const int N = 5e4+1;

map<string, ll> mp[(1<<K)];

ll ans[6], n, d;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n>>d;
    for (int i=1; i<=n; ++i) {
        string s; cin>>s;

        for (int j=1; j<(1<<K); ++j) {
            string tmp;
            for (int x=0; x<K; ++x) {
                if (j&(1<<x)) tmp+=s[x];
            }

            ++mp[j][tmp];
        }
    }

    for (int m=0; m<(1<<K); ++m) {
        ll tmp=0;
        for (auto u : mp[m]) tmp+=u.second*(u.second-1)/2;
        ans[4-__builtin_popcount(m)]+=tmp;
    }

    if (d == 1) cout<<ans[1]-ans[0]<<"\n";
    else if (d == 2) cout<<ans[2]-3*(ans[1]-ans[0])<<"\n";
    else if (d == 3) cout<<ans[3]-2*ans[2]+3*(ans[1]-ans[0])<<"\n";
    else if (d == 4) cout<<ans[4]-ans[3]+ans[2]-ans[1]+ans[0]<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 980 KB Output is correct
2 Correct 8 ms 980 KB Output is correct
3 Incorrect 4 ms 852 KB Output isn't correct
4 Correct 58 ms 3276 KB Output is correct
5 Correct 68 ms 3712 KB Output is correct
6 Correct 62 ms 3652 KB Output is correct
7 Correct 63 ms 3240 KB Output is correct
8 Correct 72 ms 3916 KB Output is correct
9 Correct 116 ms 5320 KB Output is correct
10 Correct 150 ms 5804 KB Output is correct
11 Correct 82 ms 3872 KB Output is correct
12 Correct 122 ms 5548 KB Output is correct
13 Correct 87 ms 4184 KB Output is correct
14 Incorrect 77 ms 3956 KB Output isn't correct
15 Incorrect 137 ms 5588 KB Output isn't correct
16 Correct 172 ms 11224 KB Output is correct
17 Correct 263 ms 14776 KB Output is correct
18 Incorrect 210 ms 12368 KB Output isn't correct
19 Incorrect 218 ms 13564 KB Output isn't correct
20 Incorrect 271 ms 14772 KB Output isn't correct