Submission #322023

#TimeUsernameProblemLanguageResultExecution timeMemory
322023SaraPIN (CEOI10_pin)C++14
100 / 100
114 ms51584 KiB
#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 timeMemoryGrader output
Fetching results...