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 <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
int main()
{
int L, Q;
cin >> L >> Q;
vi A((1<<L));
for(int i = 0; i < (1<<L); i++)
{
char c;
cin >> c;
A[i] = c - '0';
}
for(int j = 0; j < Q; j++)
{
int res = 0;
int mask = 0, test = 0;
for(int b = L-1; b >= 0; b--)
{
char c;
cin >> c;
if(c == '0')
test |= (1<<b);
else if(c == '1')
{
mask |= (1<<b);
test |= (1<<b);
}
}
// cerr << test << ' ' << mask << '\n';
for(int i = 0; i < (1<<L); i++)
{
if((i & test) == mask)
res += A[i];
}
cout << res << '\n';
}
}
# | 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... |