Submission #322023

# Submission time Handle Problem Language Result Execution time Memory
322023 2020-11-13T21:41:15 Z Sara PIN (CEOI10_pin) C++14
100 / 100
114 ms 51584 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N = 1e5 + 5;
const ll M = 36 + 5;
const ll K = 16 + 5; 
const ll O = 10;
ll n, d, z[O];
ll ans[O], ansp[O], res[O];
ll cn[K][M][M][M][M];
unordered_map <char, ll> f;
string a[N];
int main (){
    f['0'] = 1; f['1'] = 2; f['2'] = 3; f['3'] = 4; f['4'] = 5; f['5'] = 6; f['6'] = 7; f['7'] = 8;
    f['8'] = 9; f['9'] = 10; f['a'] = 11; f['b'] = 12; f['c'] = 13; f['d'] = 14; f['e'] = 15; f['f'] = 16;
    f['g'] = 17; f['h'] = 18; f['i'] = 19; f['j'] = 20; f['k'] = 21; f['l'] = 22; f['m'] = 23; f['n'] = 24;
    f['o'] = 25; f['p'] = 26; f['q'] = 27; f['r'] = 28; f['s'] = 29; f['t'] = 30; f['u'] = 31; f['v'] = 32;
    f['w'] = 33; f['x'] = 34; f['y'] = 35; f['z'] = 36; 
    cin >> n >> d;
    for (ll i = 0; i < n; i++){
        cin >> a[i];
        fill(ansp, ansp + O, 0);
        for (ll msk = 0; msk < 16; msk++){
            fill(z, z + O, 0);
            for (int j = 0; j < 4; j++){
                if ((msk >> j) & 1){
                    z[j] = f[a[i][j]];
                }
            }
            ansp[__builtin_popcount(msk)] += cn[msk][z[0]][z[1]][z[2]][z[3]]; 
            cn[msk][z[0]][z[1]][z[2]][z[3]] ++;
        }
        ansp[3] += -4ll * ansp[4];
        ansp[2] += -3ll * ansp[3] -6ll * ansp[4];
        ansp[1] += -2ll * ansp[2] -3ll * ansp[3] -4ll * ansp[4];
        ansp[0] += -1ll * ansp[1] -1ll * ansp[2] -1ll * ansp[3] -1ll * ansp[4];
        for (int j = 0; j < 4; j++) ans[j] += ansp[j];
    }    
    cout << ans[4 - d] << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 10476 KB Output is correct
2 Correct 9 ms 10368 KB Output is correct
3 Correct 8 ms 10092 KB Output is correct
4 Correct 29 ms 11244 KB Output is correct
5 Correct 34 ms 11372 KB Output is correct
6 Correct 33 ms 11244 KB Output is correct
7 Correct 29 ms 11264 KB Output is correct
8 Correct 36 ms 11244 KB Output is correct
9 Correct 55 ms 11372 KB Output is correct
10 Correct 58 ms 11372 KB Output is correct
11 Correct 35 ms 11244 KB Output is correct
12 Correct 55 ms 11408 KB Output is correct
13 Correct 41 ms 11244 KB Output is correct
14 Correct 36 ms 11244 KB Output is correct
15 Correct 56 ms 11372 KB Output is correct
16 Correct 86 ms 51436 KB Output is correct
17 Correct 110 ms 51564 KB Output is correct
18 Correct 92 ms 51584 KB Output is correct
19 Correct 105 ms 51564 KB Output is correct
20 Correct 114 ms 51564 KB Output is correct