#include <bits/stdc++.h>
using namespace std;
const int B = 13, N = 1<<20, SZ = pow(3, B);
int Q, dp[SZ], ans[N], id[N];
string A, inp;
short x[N], y[N];
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> Q >> Q >> A;
A.resize(N, '0');
for(int i = 0; i < Q; ++i) {
cin >> inp;
reverse(begin(inp), end(inp));
inp.resize(20, '0');
for(int k = 0, p = 1; k < B; ++k, p *= 3)
id[i] += p * ((48 < inp[k]) + (62 < inp[k]));
for(int k = 0; k < 20-B; ++k) {
if(inp[k+B] != '?') y[i] |= 1<<k;
if(inp[k+B] == '1') x[i] |= 1<<k;
}
}
for(int s = 0; s < (1<<(20-B)); ++s) {
memset(dp, 0, sizeof dp);
for(int i = 0; i < (1<<B); ++i) {
int j = 0;
for(int k = 0, p = 1; k < B; ++k, p *= 3)
if(i & (1<<k)) j += p;
dp[j] += A[i | (s << B)] - '0';
}
for(int i = 1; i < SZ; ++i) {
int j = -1, pw = 1;
for(int k = 0, p = i; k < B; ++k, p /= 3, pw *= 3)
if((p % 3) > 1) j = k, k = B;
if(j >= 0)
pw /= 3, dp[i] = dp[i - pw] + dp[i - 2 * pw];
}
for(int i = 0; i < Q; ++i)
if(!((x[i] ^ s) & y[i]))
ans[i] += dp[id[i]];
}
for(int i = 0; i < Q; ++i)
cout << ans[i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1085 ms |
7628 KB |
Output is correct |
2 |
Correct |
1132 ms |
7628 KB |
Output is correct |
3 |
Correct |
1040 ms |
7628 KB |
Output is correct |
4 |
Correct |
1069 ms |
7628 KB |
Output is correct |
5 |
Correct |
1060 ms |
7628 KB |
Output is correct |
6 |
Correct |
1041 ms |
7624 KB |
Output is correct |
7 |
Correct |
1056 ms |
7624 KB |
Output is correct |
8 |
Correct |
992 ms |
7628 KB |
Output is correct |
9 |
Correct |
995 ms |
7628 KB |
Output is correct |
10 |
Correct |
990 ms |
7628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1085 ms |
7628 KB |
Output is correct |
2 |
Correct |
1132 ms |
7628 KB |
Output is correct |
3 |
Correct |
1040 ms |
7628 KB |
Output is correct |
4 |
Correct |
1069 ms |
7628 KB |
Output is correct |
5 |
Correct |
1060 ms |
7628 KB |
Output is correct |
6 |
Correct |
1041 ms |
7624 KB |
Output is correct |
7 |
Correct |
1056 ms |
7624 KB |
Output is correct |
8 |
Correct |
992 ms |
7628 KB |
Output is correct |
9 |
Correct |
995 ms |
7628 KB |
Output is correct |
10 |
Correct |
990 ms |
7628 KB |
Output is correct |
11 |
Correct |
1302 ms |
25576 KB |
Output is correct |
12 |
Correct |
1302 ms |
25056 KB |
Output is correct |
13 |
Correct |
1300 ms |
24424 KB |
Output is correct |
14 |
Correct |
1326 ms |
24424 KB |
Output is correct |
15 |
Correct |
1309 ms |
25444 KB |
Output is correct |
16 |
Correct |
1288 ms |
24564 KB |
Output is correct |
17 |
Correct |
1312 ms |
24612 KB |
Output is correct |
18 |
Correct |
1281 ms |
26564 KB |
Output is correct |
19 |
Correct |
1293 ms |
23472 KB |
Output is correct |
20 |
Correct |
1297 ms |
25104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1085 ms |
7628 KB |
Output is correct |
2 |
Correct |
1132 ms |
7628 KB |
Output is correct |
3 |
Correct |
1040 ms |
7628 KB |
Output is correct |
4 |
Correct |
1069 ms |
7628 KB |
Output is correct |
5 |
Correct |
1060 ms |
7628 KB |
Output is correct |
6 |
Correct |
1041 ms |
7624 KB |
Output is correct |
7 |
Correct |
1056 ms |
7624 KB |
Output is correct |
8 |
Correct |
992 ms |
7628 KB |
Output is correct |
9 |
Correct |
995 ms |
7628 KB |
Output is correct |
10 |
Correct |
990 ms |
7628 KB |
Output is correct |
11 |
Correct |
1302 ms |
25576 KB |
Output is correct |
12 |
Correct |
1302 ms |
25056 KB |
Output is correct |
13 |
Correct |
1300 ms |
24424 KB |
Output is correct |
14 |
Correct |
1326 ms |
24424 KB |
Output is correct |
15 |
Correct |
1309 ms |
25444 KB |
Output is correct |
16 |
Correct |
1288 ms |
24564 KB |
Output is correct |
17 |
Correct |
1312 ms |
24612 KB |
Output is correct |
18 |
Correct |
1281 ms |
26564 KB |
Output is correct |
19 |
Correct |
1293 ms |
23472 KB |
Output is correct |
20 |
Correct |
1297 ms |
25104 KB |
Output is correct |
21 |
Correct |
1305 ms |
24716 KB |
Output is correct |
22 |
Correct |
1299 ms |
24940 KB |
Output is correct |
23 |
Correct |
1298 ms |
23936 KB |
Output is correct |
24 |
Correct |
1305 ms |
23732 KB |
Output is correct |
25 |
Correct |
1299 ms |
25704 KB |
Output is correct |
26 |
Correct |
1322 ms |
24168 KB |
Output is correct |
27 |
Correct |
1317 ms |
24260 KB |
Output is correct |
28 |
Correct |
1307 ms |
26604 KB |
Output is correct |
29 |
Correct |
1310 ms |
22540 KB |
Output is correct |
30 |
Correct |
1322 ms |
24740 KB |
Output is correct |
31 |
Correct |
1315 ms |
24588 KB |
Output is correct |
32 |
Correct |
1305 ms |
24464 KB |
Output is correct |
33 |
Correct |
1327 ms |
23312 KB |
Output is correct |
34 |
Correct |
1302 ms |
23548 KB |
Output is correct |
35 |
Correct |
1299 ms |
23816 KB |
Output is correct |
36 |
Correct |
1298 ms |
22460 KB |
Output is correct |
37 |
Correct |
1293 ms |
24208 KB |
Output is correct |
38 |
Correct |
1324 ms |
22212 KB |
Output is correct |
39 |
Correct |
1299 ms |
23388 KB |
Output is correct |
40 |
Correct |
1303 ms |
23108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1085 ms |
7628 KB |
Output is correct |
2 |
Correct |
1132 ms |
7628 KB |
Output is correct |
3 |
Correct |
1040 ms |
7628 KB |
Output is correct |
4 |
Correct |
1069 ms |
7628 KB |
Output is correct |
5 |
Correct |
1060 ms |
7628 KB |
Output is correct |
6 |
Correct |
1041 ms |
7624 KB |
Output is correct |
7 |
Correct |
1056 ms |
7624 KB |
Output is correct |
8 |
Correct |
992 ms |
7628 KB |
Output is correct |
9 |
Correct |
995 ms |
7628 KB |
Output is correct |
10 |
Correct |
990 ms |
7628 KB |
Output is correct |
11 |
Correct |
1022 ms |
10500 KB |
Output is correct |
12 |
Correct |
1022 ms |
10532 KB |
Output is correct |
13 |
Correct |
1010 ms |
10500 KB |
Output is correct |
14 |
Correct |
1008 ms |
10600 KB |
Output is correct |
15 |
Correct |
1034 ms |
10632 KB |
Output is correct |
16 |
Correct |
1020 ms |
10596 KB |
Output is correct |
17 |
Correct |
1014 ms |
10532 KB |
Output is correct |
18 |
Correct |
1006 ms |
10560 KB |
Output is correct |
19 |
Correct |
1002 ms |
10472 KB |
Output is correct |
20 |
Correct |
1014 ms |
10724 KB |
Output is correct |
21 |
Correct |
1029 ms |
10608 KB |
Output is correct |
22 |
Correct |
1006 ms |
10540 KB |
Output is correct |
23 |
Correct |
1014 ms |
10612 KB |
Output is correct |
24 |
Correct |
1016 ms |
10540 KB |
Output is correct |
25 |
Correct |
1012 ms |
10628 KB |
Output is correct |
26 |
Correct |
1004 ms |
10424 KB |
Output is correct |
27 |
Correct |
1032 ms |
10400 KB |
Output is correct |
28 |
Correct |
998 ms |
10368 KB |
Output is correct |
29 |
Correct |
997 ms |
10520 KB |
Output is correct |
30 |
Correct |
1002 ms |
10608 KB |
Output is correct |
31 |
Correct |
1006 ms |
10500 KB |
Output is correct |
32 |
Correct |
1028 ms |
10592 KB |
Output is correct |
33 |
Correct |
1032 ms |
10508 KB |
Output is correct |
34 |
Correct |
1002 ms |
10340 KB |
Output is correct |
35 |
Correct |
1022 ms |
10496 KB |
Output is correct |
36 |
Correct |
1004 ms |
10592 KB |
Output is correct |
37 |
Correct |
1016 ms |
10528 KB |
Output is correct |
38 |
Correct |
1026 ms |
10596 KB |
Output is correct |
39 |
Correct |
1028 ms |
10520 KB |
Output is correct |
40 |
Correct |
1018 ms |
10468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1085 ms |
7628 KB |
Output is correct |
2 |
Correct |
1132 ms |
7628 KB |
Output is correct |
3 |
Correct |
1040 ms |
7628 KB |
Output is correct |
4 |
Correct |
1069 ms |
7628 KB |
Output is correct |
5 |
Correct |
1060 ms |
7628 KB |
Output is correct |
6 |
Correct |
1041 ms |
7624 KB |
Output is correct |
7 |
Correct |
1056 ms |
7624 KB |
Output is correct |
8 |
Correct |
992 ms |
7628 KB |
Output is correct |
9 |
Correct |
995 ms |
7628 KB |
Output is correct |
10 |
Correct |
990 ms |
7628 KB |
Output is correct |
11 |
Correct |
1302 ms |
25576 KB |
Output is correct |
12 |
Correct |
1302 ms |
25056 KB |
Output is correct |
13 |
Correct |
1300 ms |
24424 KB |
Output is correct |
14 |
Correct |
1326 ms |
24424 KB |
Output is correct |
15 |
Correct |
1309 ms |
25444 KB |
Output is correct |
16 |
Correct |
1288 ms |
24564 KB |
Output is correct |
17 |
Correct |
1312 ms |
24612 KB |
Output is correct |
18 |
Correct |
1281 ms |
26564 KB |
Output is correct |
19 |
Correct |
1293 ms |
23472 KB |
Output is correct |
20 |
Correct |
1297 ms |
25104 KB |
Output is correct |
21 |
Correct |
1305 ms |
24716 KB |
Output is correct |
22 |
Correct |
1299 ms |
24940 KB |
Output is correct |
23 |
Correct |
1298 ms |
23936 KB |
Output is correct |
24 |
Correct |
1305 ms |
23732 KB |
Output is correct |
25 |
Correct |
1299 ms |
25704 KB |
Output is correct |
26 |
Correct |
1322 ms |
24168 KB |
Output is correct |
27 |
Correct |
1317 ms |
24260 KB |
Output is correct |
28 |
Correct |
1307 ms |
26604 KB |
Output is correct |
29 |
Correct |
1310 ms |
22540 KB |
Output is correct |
30 |
Correct |
1322 ms |
24740 KB |
Output is correct |
31 |
Correct |
1315 ms |
24588 KB |
Output is correct |
32 |
Correct |
1305 ms |
24464 KB |
Output is correct |
33 |
Correct |
1327 ms |
23312 KB |
Output is correct |
34 |
Correct |
1302 ms |
23548 KB |
Output is correct |
35 |
Correct |
1299 ms |
23816 KB |
Output is correct |
36 |
Correct |
1298 ms |
22460 KB |
Output is correct |
37 |
Correct |
1293 ms |
24208 KB |
Output is correct |
38 |
Correct |
1324 ms |
22212 KB |
Output is correct |
39 |
Correct |
1299 ms |
23388 KB |
Output is correct |
40 |
Correct |
1303 ms |
23108 KB |
Output is correct |
41 |
Correct |
1022 ms |
10500 KB |
Output is correct |
42 |
Correct |
1022 ms |
10532 KB |
Output is correct |
43 |
Correct |
1010 ms |
10500 KB |
Output is correct |
44 |
Correct |
1008 ms |
10600 KB |
Output is correct |
45 |
Correct |
1034 ms |
10632 KB |
Output is correct |
46 |
Correct |
1020 ms |
10596 KB |
Output is correct |
47 |
Correct |
1014 ms |
10532 KB |
Output is correct |
48 |
Correct |
1006 ms |
10560 KB |
Output is correct |
49 |
Correct |
1002 ms |
10472 KB |
Output is correct |
50 |
Correct |
1014 ms |
10724 KB |
Output is correct |
51 |
Correct |
1029 ms |
10608 KB |
Output is correct |
52 |
Correct |
1006 ms |
10540 KB |
Output is correct |
53 |
Correct |
1014 ms |
10612 KB |
Output is correct |
54 |
Correct |
1016 ms |
10540 KB |
Output is correct |
55 |
Correct |
1012 ms |
10628 KB |
Output is correct |
56 |
Correct |
1004 ms |
10424 KB |
Output is correct |
57 |
Correct |
1032 ms |
10400 KB |
Output is correct |
58 |
Correct |
998 ms |
10368 KB |
Output is correct |
59 |
Correct |
997 ms |
10520 KB |
Output is correct |
60 |
Correct |
1002 ms |
10608 KB |
Output is correct |
61 |
Correct |
1006 ms |
10500 KB |
Output is correct |
62 |
Correct |
1028 ms |
10592 KB |
Output is correct |
63 |
Correct |
1032 ms |
10508 KB |
Output is correct |
64 |
Correct |
1002 ms |
10340 KB |
Output is correct |
65 |
Correct |
1022 ms |
10496 KB |
Output is correct |
66 |
Correct |
1004 ms |
10592 KB |
Output is correct |
67 |
Correct |
1016 ms |
10528 KB |
Output is correct |
68 |
Correct |
1026 ms |
10596 KB |
Output is correct |
69 |
Correct |
1028 ms |
10520 KB |
Output is correct |
70 |
Correct |
1018 ms |
10468 KB |
Output is correct |
71 |
Correct |
1541 ms |
25328 KB |
Output is correct |
72 |
Correct |
1510 ms |
23380 KB |
Output is correct |
73 |
Correct |
1546 ms |
23824 KB |
Output is correct |
74 |
Correct |
1635 ms |
24408 KB |
Output is correct |
75 |
Correct |
1755 ms |
26228 KB |
Output is correct |
76 |
Correct |
1633 ms |
24436 KB |
Output is correct |
77 |
Correct |
1632 ms |
24312 KB |
Output is correct |
78 |
Correct |
1370 ms |
24424 KB |
Output is correct |
79 |
Correct |
1465 ms |
22124 KB |
Output is correct |
80 |
Correct |
1534 ms |
25444 KB |
Output is correct |
81 |
Correct |
1708 ms |
25132 KB |
Output is correct |
82 |
Correct |
1607 ms |
24168 KB |
Output is correct |
83 |
Correct |
1445 ms |
23264 KB |
Output is correct |
84 |
Correct |
1611 ms |
24164 KB |
Output is correct |
85 |
Correct |
1683 ms |
24408 KB |
Output is correct |
86 |
Correct |
1326 ms |
22244 KB |
Output is correct |
87 |
Correct |
1517 ms |
23316 KB |
Output is correct |
88 |
Correct |
1550 ms |
22244 KB |
Output is correct |
89 |
Correct |
1791 ms |
23764 KB |
Output is correct |
90 |
Correct |
1710 ms |
24140 KB |
Output is correct |
91 |
Correct |
1535 ms |
23228 KB |
Output is correct |
92 |
Correct |
1740 ms |
24472 KB |
Output is correct |
93 |
Correct |
1666 ms |
24220 KB |
Output is correct |
94 |
Correct |
1308 ms |
20092 KB |
Output is correct |
95 |
Correct |
1650 ms |
24172 KB |
Output is correct |
96 |
Correct |
1659 ms |
24160 KB |
Output is correct |
97 |
Correct |
1716 ms |
24100 KB |
Output is correct |
98 |
Correct |
1806 ms |
24112 KB |
Output is correct |
99 |
Correct |
1782 ms |
24100 KB |
Output is correct |
100 |
Correct |
1744 ms |
23972 KB |
Output is correct |