#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")*/
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr
void solve() {
int l, q;
string s;
cin >> l >> q >> s;
loop(i, q) {
string t; cin >> t;
reverse(all(t));
int ans = 0;
loop(i, (1ll << l)) {
bool f = 1;
loop(bit, l)
if (t[bit] != '?' && bool(i & (1ll << bit)) != t[bit] - '0') {
f = 0; break;
}
if (f)
ans += s[i] - '0';
}
cout << ans << "\n";
}
}
signed main() {
//freopen("b2.txt", "r", stdin);
//freopen("ans9.txt", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//int t; cin >> t; loop(i, t)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
7 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
16 ms |
364 KB |
Output is correct |
9 |
Correct |
6 ms |
364 KB |
Output is correct |
10 |
Correct |
9 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
7 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
16 ms |
364 KB |
Output is correct |
9 |
Correct |
6 ms |
364 KB |
Output is correct |
10 |
Correct |
9 ms |
364 KB |
Output is correct |
11 |
Execution timed out |
2075 ms |
4720 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
7 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
16 ms |
364 KB |
Output is correct |
9 |
Correct |
6 ms |
364 KB |
Output is correct |
10 |
Correct |
9 ms |
364 KB |
Output is correct |
11 |
Execution timed out |
2075 ms |
4720 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
7 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
16 ms |
364 KB |
Output is correct |
9 |
Correct |
6 ms |
364 KB |
Output is correct |
10 |
Correct |
9 ms |
364 KB |
Output is correct |
11 |
Execution timed out |
2087 ms |
3720 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
5 |
Correct |
8 ms |
364 KB |
Output is correct |
6 |
Correct |
7 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
16 ms |
364 KB |
Output is correct |
9 |
Correct |
6 ms |
364 KB |
Output is correct |
10 |
Correct |
9 ms |
364 KB |
Output is correct |
11 |
Execution timed out |
2075 ms |
4720 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |