//#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;
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 |
261 ms |
4796 KB |
Output is correct |
2 |
Correct |
250 ms |
5028 KB |
Output is correct |
3 |
Correct |
267 ms |
4960 KB |
Output is correct |
4 |
Correct |
248 ms |
4792 KB |
Output is correct |
5 |
Correct |
250 ms |
4804 KB |
Output is correct |
6 |
Correct |
255 ms |
4868 KB |
Output is correct |
7 |
Correct |
257 ms |
4888 KB |
Output is correct |
8 |
Correct |
246 ms |
4892 KB |
Output is correct |
9 |
Correct |
253 ms |
4864 KB |
Output is correct |
10 |
Correct |
251 ms |
4804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
4796 KB |
Output is correct |
2 |
Correct |
250 ms |
5028 KB |
Output is correct |
3 |
Correct |
267 ms |
4960 KB |
Output is correct |
4 |
Correct |
248 ms |
4792 KB |
Output is correct |
5 |
Correct |
250 ms |
4804 KB |
Output is correct |
6 |
Correct |
255 ms |
4868 KB |
Output is correct |
7 |
Correct |
257 ms |
4888 KB |
Output is correct |
8 |
Correct |
246 ms |
4892 KB |
Output is correct |
9 |
Correct |
253 ms |
4864 KB |
Output is correct |
10 |
Correct |
251 ms |
4804 KB |
Output is correct |
11 |
Execution timed out |
2023 ms |
19620 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
4796 KB |
Output is correct |
2 |
Correct |
250 ms |
5028 KB |
Output is correct |
3 |
Correct |
267 ms |
4960 KB |
Output is correct |
4 |
Correct |
248 ms |
4792 KB |
Output is correct |
5 |
Correct |
250 ms |
4804 KB |
Output is correct |
6 |
Correct |
255 ms |
4868 KB |
Output is correct |
7 |
Correct |
257 ms |
4888 KB |
Output is correct |
8 |
Correct |
246 ms |
4892 KB |
Output is correct |
9 |
Correct |
253 ms |
4864 KB |
Output is correct |
10 |
Correct |
251 ms |
4804 KB |
Output is correct |
11 |
Execution timed out |
2023 ms |
19620 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
4796 KB |
Output is correct |
2 |
Correct |
250 ms |
5028 KB |
Output is correct |
3 |
Correct |
267 ms |
4960 KB |
Output is correct |
4 |
Correct |
248 ms |
4792 KB |
Output is correct |
5 |
Correct |
250 ms |
4804 KB |
Output is correct |
6 |
Correct |
255 ms |
4868 KB |
Output is correct |
7 |
Correct |
257 ms |
4888 KB |
Output is correct |
8 |
Correct |
246 ms |
4892 KB |
Output is correct |
9 |
Correct |
253 ms |
4864 KB |
Output is correct |
10 |
Correct |
251 ms |
4804 KB |
Output is correct |
11 |
Runtime error |
298 ms |
65540 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
4796 KB |
Output is correct |
2 |
Correct |
250 ms |
5028 KB |
Output is correct |
3 |
Correct |
267 ms |
4960 KB |
Output is correct |
4 |
Correct |
248 ms |
4792 KB |
Output is correct |
5 |
Correct |
250 ms |
4804 KB |
Output is correct |
6 |
Correct |
255 ms |
4868 KB |
Output is correct |
7 |
Correct |
257 ms |
4888 KB |
Output is correct |
8 |
Correct |
246 ms |
4892 KB |
Output is correct |
9 |
Correct |
253 ms |
4864 KB |
Output is correct |
10 |
Correct |
251 ms |
4804 KB |
Output is correct |
11 |
Execution timed out |
2023 ms |
19620 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |