#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int l, q; cin >> l >> q;
string tox; cin >> tox;
while (q--){
string s; cin >> s;
int ans = 0;
for (int mask = 0; mask < (1 << l); mask++){
bool add = true;
for (int i = l-1; i >= 0; i--){
if (s[i] != '?' && (s[i]-'0') != (bool)((mask >> (l-i-1)) & 1)){
add = false;
break;
}
}
if (add)
ans += tox[mask]-'0';
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
9 ms |
456 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
9 ms |
456 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
2045 ms |
1876 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
9 ms |
456 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
2045 ms |
1876 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
9 ms |
456 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
2044 ms |
2552 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
460 KB |
Output is correct |
8 |
Correct |
9 ms |
456 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
2045 ms |
1876 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |