#include<iostream>
#include<string>
using namespace std;
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define all(x) x.begin(),x.end()
string str;
int n;
map<string, int> mp;
string itos(int a, int l) {
string res = "";
for (int i = 0; i < l; i++) {
res += '0' + (a & 1);
a >>= 1;
}
reverse(all(res));
return res;
}
void init(int N, int Q, string S) {
n = N;
str = S;
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < (1 << n); j++) {
string s = itos(i, n);
for (int w = 0; w < n; w++) if (j & (1 << w)) s[w] = '?';
mp[s] += S[i]-'0';
}
}
}
int query(string A) {
return mp[A];
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int N, Q; cin >> N >> Q;
string S; cin >> S;
init(N, Q, move(S));
for (int i = 0; i < Q; i++) {
string A;
cin >> A;
cout << query(move(A)) << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
4944 KB |
Output is correct |
2 |
Correct |
233 ms |
4944 KB |
Output is correct |
3 |
Correct |
239 ms |
4896 KB |
Output is correct |
4 |
Correct |
236 ms |
4964 KB |
Output is correct |
5 |
Correct |
234 ms |
4944 KB |
Output is correct |
6 |
Correct |
236 ms |
5052 KB |
Output is correct |
7 |
Correct |
245 ms |
4944 KB |
Output is correct |
8 |
Correct |
242 ms |
5204 KB |
Output is correct |
9 |
Correct |
236 ms |
4944 KB |
Output is correct |
10 |
Correct |
246 ms |
4940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
4944 KB |
Output is correct |
2 |
Correct |
233 ms |
4944 KB |
Output is correct |
3 |
Correct |
239 ms |
4896 KB |
Output is correct |
4 |
Correct |
236 ms |
4964 KB |
Output is correct |
5 |
Correct |
234 ms |
4944 KB |
Output is correct |
6 |
Correct |
236 ms |
5052 KB |
Output is correct |
7 |
Correct |
245 ms |
4944 KB |
Output is correct |
8 |
Correct |
242 ms |
5204 KB |
Output is correct |
9 |
Correct |
236 ms |
4944 KB |
Output is correct |
10 |
Correct |
246 ms |
4940 KB |
Output is correct |
11 |
Correct |
1658 ms |
14760 KB |
Output is correct |
12 |
Correct |
1670 ms |
19492 KB |
Output is correct |
13 |
Correct |
1648 ms |
18660 KB |
Output is correct |
14 |
Correct |
1705 ms |
18692 KB |
Output is correct |
15 |
Correct |
1732 ms |
19828 KB |
Output is correct |
16 |
Correct |
1777 ms |
18828 KB |
Output is correct |
17 |
Correct |
1792 ms |
18880 KB |
Output is correct |
18 |
Correct |
1532 ms |
20772 KB |
Output is correct |
19 |
Correct |
1652 ms |
17824 KB |
Output is correct |
20 |
Correct |
1751 ms |
19344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
4944 KB |
Output is correct |
2 |
Correct |
233 ms |
4944 KB |
Output is correct |
3 |
Correct |
239 ms |
4896 KB |
Output is correct |
4 |
Correct |
236 ms |
4964 KB |
Output is correct |
5 |
Correct |
234 ms |
4944 KB |
Output is correct |
6 |
Correct |
236 ms |
5052 KB |
Output is correct |
7 |
Correct |
245 ms |
4944 KB |
Output is correct |
8 |
Correct |
242 ms |
5204 KB |
Output is correct |
9 |
Correct |
236 ms |
4944 KB |
Output is correct |
10 |
Correct |
246 ms |
4940 KB |
Output is correct |
11 |
Correct |
1658 ms |
14760 KB |
Output is correct |
12 |
Correct |
1670 ms |
19492 KB |
Output is correct |
13 |
Correct |
1648 ms |
18660 KB |
Output is correct |
14 |
Correct |
1705 ms |
18692 KB |
Output is correct |
15 |
Correct |
1732 ms |
19828 KB |
Output is correct |
16 |
Correct |
1777 ms |
18828 KB |
Output is correct |
17 |
Correct |
1792 ms |
18880 KB |
Output is correct |
18 |
Correct |
1532 ms |
20772 KB |
Output is correct |
19 |
Correct |
1652 ms |
17824 KB |
Output is correct |
20 |
Correct |
1751 ms |
19344 KB |
Output is correct |
21 |
Execution timed out |
2029 ms |
36960 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
4944 KB |
Output is correct |
2 |
Correct |
233 ms |
4944 KB |
Output is correct |
3 |
Correct |
239 ms |
4896 KB |
Output is correct |
4 |
Correct |
236 ms |
4964 KB |
Output is correct |
5 |
Correct |
234 ms |
4944 KB |
Output is correct |
6 |
Correct |
236 ms |
5052 KB |
Output is correct |
7 |
Correct |
245 ms |
4944 KB |
Output is correct |
8 |
Correct |
242 ms |
5204 KB |
Output is correct |
9 |
Correct |
236 ms |
4944 KB |
Output is correct |
10 |
Correct |
246 ms |
4940 KB |
Output is correct |
11 |
Runtime error |
270 ms |
65536 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
4944 KB |
Output is correct |
2 |
Correct |
233 ms |
4944 KB |
Output is correct |
3 |
Correct |
239 ms |
4896 KB |
Output is correct |
4 |
Correct |
236 ms |
4964 KB |
Output is correct |
5 |
Correct |
234 ms |
4944 KB |
Output is correct |
6 |
Correct |
236 ms |
5052 KB |
Output is correct |
7 |
Correct |
245 ms |
4944 KB |
Output is correct |
8 |
Correct |
242 ms |
5204 KB |
Output is correct |
9 |
Correct |
236 ms |
4944 KB |
Output is correct |
10 |
Correct |
246 ms |
4940 KB |
Output is correct |
11 |
Correct |
1658 ms |
14760 KB |
Output is correct |
12 |
Correct |
1670 ms |
19492 KB |
Output is correct |
13 |
Correct |
1648 ms |
18660 KB |
Output is correct |
14 |
Correct |
1705 ms |
18692 KB |
Output is correct |
15 |
Correct |
1732 ms |
19828 KB |
Output is correct |
16 |
Correct |
1777 ms |
18828 KB |
Output is correct |
17 |
Correct |
1792 ms |
18880 KB |
Output is correct |
18 |
Correct |
1532 ms |
20772 KB |
Output is correct |
19 |
Correct |
1652 ms |
17824 KB |
Output is correct |
20 |
Correct |
1751 ms |
19344 KB |
Output is correct |
21 |
Execution timed out |
2029 ms |
36960 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |