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;
#define int long long
signed main(){
int l, q;
cin >> l >> q;
string toxicities;
cin >> toxicities;
while (q--){
string s;
cin >> s;
int ans = 0;
for (int bm = 0; bm < (1 << l); bm++){
bool add = true;
for (int i = l - 1; i >= 0; i--){
if (s[i] == '0' || s[i] == '1'){
int s_digit = s[i] - '0';
int bm_bit = (bm >> (l - i - 1)) & 1;
if (s_digit != bm_bit) {
add = false;
break;
}
}
}
if (add){
ans += toxicities[bm]-'0';
}
}
cout << ans << endl;
}
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... |