This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#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;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |