# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544778 | 2022-04-02T16:43:16 Z | rainboy | PIN (CEOI10_pin) | C | 22 ms | 7308 KB |
#include <ctype.h> #include <stdio.h> #define N 50000 #define K 4 #define B 36 #define A (B * B * B * B) int code(char *cc, int b) { int h, a; a = 0; for (h = 0; h < K; h++) a = a * B + ((b & 1 << h) != 0 ? cc[h] : 0); return a; } int count(int b) { return b == 0 ? 0 : count(b & b - 1) + 1; } int main() { static char cc[N][K + 1]; static int cnt[A]; static long long kk[1 << K]; int n, m, h, i, b, ans; scanf("%d%d", &n, &m), m = 4 - m; for (i = 0; i < n; i++) { scanf("%s", cc[i]); for (h = 0; h < K; h++) cc[i][h] = isdigit(cc[i][h]) ? cc[i][h] - '0' : cc[i][h] - 'a' + 10; } for (b = 0; b < 1 << K; b++) { for (i = 0; i < n; i++) kk[b] += cnt[code(cc[i], b)]++; for (i = 0; i < n; i++) cnt[code(cc[i], b)]--; } for (h = 0; h < K; h++) for (b = 0; b < 1 << K; b++) if ((b & 1 << h) == 0) kk[b] -= kk[b | 1 << h]; ans = 0; for (b = 0; b < 1 << K; b++) if (count(b) == m) ans += kk[b]; printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1620 KB | Output is correct |
2 | Correct | 2 ms | 1492 KB | Output is correct |
3 | Correct | 2 ms | 1492 KB | Output is correct |
4 | Correct | 8 ms | 1800 KB | Output is correct |
5 | Correct | 12 ms | 1828 KB | Output is correct |
6 | Correct | 9 ms | 1752 KB | Output is correct |
7 | Correct | 8 ms | 1804 KB | Output is correct |
8 | Correct | 10 ms | 1876 KB | Output is correct |
9 | Correct | 15 ms | 1960 KB | Output is correct |
10 | Correct | 15 ms | 2048 KB | Output is correct |
11 | Correct | 9 ms | 1748 KB | Output is correct |
12 | Correct | 14 ms | 2012 KB | Output is correct |
13 | Correct | 13 ms | 1848 KB | Output is correct |
14 | Correct | 9 ms | 1876 KB | Output is correct |
15 | Correct | 19 ms | 1960 KB | Output is correct |
16 | Correct | 17 ms | 7152 KB | Output is correct |
17 | Correct | 21 ms | 7304 KB | Output is correct |
18 | Correct | 16 ms | 7216 KB | Output is correct |
19 | Correct | 22 ms | 7200 KB | Output is correct |
20 | Correct | 20 ms | 7308 KB | Output is correct |