Submission #502473

# Submission time Handle Problem Language Result Execution time Memory
502473 2022-01-06T05:24:12 Z zorianka Stove (JOI18_stove) C++17
0 / 100
156 ms 4580 KB
//#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;
    d.reserve(1 << l);
    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
1 Incorrect 156 ms 4580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 156 ms 4580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 156 ms 4580 KB Output isn't correct
2 Halted 0 ms 0 KB -