//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int l, q;
cin >> l >> q;
string s;
cin >> s;
unordered_map<string, int> d;
for (int i = 0; i < (1 << l); i++) {
for (int mask = 0; mask < (1 << l); mask++) {
string t = "";
for (int j = l - 1; j > -1; j--) {
if (mask & (1 << j))
t += '?';
else
t += '0' + ((i & (1 << j)) != 0);
}
d[t] += s[i] - '0';
}
}
while (q--){
string t;
cin >> t;
cout << d[t] << '\n';
}
}
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
4604 KB |
Output is correct |
2 |
Correct |
153 ms |
4564 KB |
Output is correct |
3 |
Correct |
154 ms |
4608 KB |
Output is correct |
4 |
Correct |
153 ms |
4552 KB |
Output is correct |
5 |
Correct |
147 ms |
4636 KB |
Output is correct |
6 |
Correct |
151 ms |
4648 KB |
Output is correct |
7 |
Correct |
169 ms |
4644 KB |
Output is correct |
8 |
Correct |
185 ms |
4540 KB |
Output is correct |
9 |
Correct |
151 ms |
4536 KB |
Output is correct |
10 |
Correct |
148 ms |
4608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
4604 KB |
Output is correct |
2 |
Correct |
153 ms |
4564 KB |
Output is correct |
3 |
Correct |
154 ms |
4608 KB |
Output is correct |
4 |
Correct |
153 ms |
4552 KB |
Output is correct |
5 |
Correct |
147 ms |
4636 KB |
Output is correct |
6 |
Correct |
151 ms |
4648 KB |
Output is correct |
7 |
Correct |
169 ms |
4644 KB |
Output is correct |
8 |
Correct |
185 ms |
4540 KB |
Output is correct |
9 |
Correct |
151 ms |
4536 KB |
Output is correct |
10 |
Correct |
148 ms |
4608 KB |
Output is correct |
11 |
Correct |
1742 ms |
8836 KB |
Output is correct |
12 |
Correct |
1785 ms |
19024 KB |
Output is correct |
13 |
Correct |
1816 ms |
18396 KB |
Output is correct |
14 |
Correct |
1817 ms |
18348 KB |
Output is correct |
15 |
Correct |
1833 ms |
19416 KB |
Output is correct |
16 |
Correct |
1846 ms |
18592 KB |
Output is correct |
17 |
Correct |
1887 ms |
18464 KB |
Output is correct |
18 |
Correct |
1764 ms |
20584 KB |
Output is correct |
19 |
Correct |
1755 ms |
17336 KB |
Output is correct |
20 |
Correct |
1763 ms |
19132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
4604 KB |
Output is correct |
2 |
Correct |
153 ms |
4564 KB |
Output is correct |
3 |
Correct |
154 ms |
4608 KB |
Output is correct |
4 |
Correct |
153 ms |
4552 KB |
Output is correct |
5 |
Correct |
147 ms |
4636 KB |
Output is correct |
6 |
Correct |
151 ms |
4648 KB |
Output is correct |
7 |
Correct |
169 ms |
4644 KB |
Output is correct |
8 |
Correct |
185 ms |
4540 KB |
Output is correct |
9 |
Correct |
151 ms |
4536 KB |
Output is correct |
10 |
Correct |
148 ms |
4608 KB |
Output is correct |
11 |
Correct |
1742 ms |
8836 KB |
Output is correct |
12 |
Correct |
1785 ms |
19024 KB |
Output is correct |
13 |
Correct |
1816 ms |
18396 KB |
Output is correct |
14 |
Correct |
1817 ms |
18348 KB |
Output is correct |
15 |
Correct |
1833 ms |
19416 KB |
Output is correct |
16 |
Correct |
1846 ms |
18592 KB |
Output is correct |
17 |
Correct |
1887 ms |
18464 KB |
Output is correct |
18 |
Correct |
1764 ms |
20584 KB |
Output is correct |
19 |
Correct |
1755 ms |
17336 KB |
Output is correct |
20 |
Correct |
1763 ms |
19132 KB |
Output is correct |
21 |
Execution timed out |
2069 ms |
37124 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
4604 KB |
Output is correct |
2 |
Correct |
153 ms |
4564 KB |
Output is correct |
3 |
Correct |
154 ms |
4608 KB |
Output is correct |
4 |
Correct |
153 ms |
4552 KB |
Output is correct |
5 |
Correct |
147 ms |
4636 KB |
Output is correct |
6 |
Correct |
151 ms |
4648 KB |
Output is correct |
7 |
Correct |
169 ms |
4644 KB |
Output is correct |
8 |
Correct |
185 ms |
4540 KB |
Output is correct |
9 |
Correct |
151 ms |
4536 KB |
Output is correct |
10 |
Correct |
148 ms |
4608 KB |
Output is correct |
11 |
Runtime error |
376 ms |
65540 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
4604 KB |
Output is correct |
2 |
Correct |
153 ms |
4564 KB |
Output is correct |
3 |
Correct |
154 ms |
4608 KB |
Output is correct |
4 |
Correct |
153 ms |
4552 KB |
Output is correct |
5 |
Correct |
147 ms |
4636 KB |
Output is correct |
6 |
Correct |
151 ms |
4648 KB |
Output is correct |
7 |
Correct |
169 ms |
4644 KB |
Output is correct |
8 |
Correct |
185 ms |
4540 KB |
Output is correct |
9 |
Correct |
151 ms |
4536 KB |
Output is correct |
10 |
Correct |
148 ms |
4608 KB |
Output is correct |
11 |
Correct |
1742 ms |
8836 KB |
Output is correct |
12 |
Correct |
1785 ms |
19024 KB |
Output is correct |
13 |
Correct |
1816 ms |
18396 KB |
Output is correct |
14 |
Correct |
1817 ms |
18348 KB |
Output is correct |
15 |
Correct |
1833 ms |
19416 KB |
Output is correct |
16 |
Correct |
1846 ms |
18592 KB |
Output is correct |
17 |
Correct |
1887 ms |
18464 KB |
Output is correct |
18 |
Correct |
1764 ms |
20584 KB |
Output is correct |
19 |
Correct |
1755 ms |
17336 KB |
Output is correct |
20 |
Correct |
1763 ms |
19132 KB |
Output is correct |
21 |
Execution timed out |
2069 ms |
37124 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |