This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (1 << 20) + 12, MOD = 998244353;
int n, q;
string s;
void test() {
cin >> n >> q;
cin >> s;
while(q--) {
string t;
cin >> t;
reverse(t.begin(), t.end());
int res = 0;
for(int i = 0; i < (1 << n); i++) {
bool ok = 1;
for(int j = 0; j < n; j++) {
if(t[j] == '?') continue;
int x = (t[j] - '0');
if(x != ((i >> j) & 1)) {
ok = 0;
break;
}
}
if(ok) {
res += (s[i] - '0');
}
}
cout << res << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
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... |