#include <bits/stdc++.h>
using namespace std;
int main()
{
int lg,q;cin>>lg>>q;
string sss;cin>>sss;
int n=1<<lg,a[n+1];
for(int i=0;i<n;i++) a[i]=sss[i]-'0';
while(q--)
{
string s;cin>>s;
int res=0;
for(int i=0;i<n;i++)
{
bool bul=true;
int temp=i,ct=lg-1;
while(ct>=0)
{
if(s[ct]!='?' && (s[ct]-'0')!=temp%2) bul=false;
temp/=2;
ct--;
}
if(bul) res+=a[i];
}
cout<<res<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
600 KB |
Output is correct |
3 |
Correct |
12 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
456 KB |
Output is correct |
9 |
Correct |
10 ms |
344 KB |
Output is correct |
10 |
Correct |
13 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
600 KB |
Output is correct |
3 |
Correct |
12 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
456 KB |
Output is correct |
9 |
Correct |
10 ms |
344 KB |
Output is correct |
10 |
Correct |
13 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2059 ms |
2928 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
600 KB |
Output is correct |
3 |
Correct |
12 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
456 KB |
Output is correct |
9 |
Correct |
10 ms |
344 KB |
Output is correct |
10 |
Correct |
13 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2059 ms |
2928 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
600 KB |
Output is correct |
3 |
Correct |
12 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
456 KB |
Output is correct |
9 |
Correct |
10 ms |
344 KB |
Output is correct |
10 |
Correct |
13 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2021 ms |
6940 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
344 KB |
Output is correct |
2 |
Correct |
13 ms |
600 KB |
Output is correct |
3 |
Correct |
12 ms |
344 KB |
Output is correct |
4 |
Correct |
12 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
12 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
456 KB |
Output is correct |
9 |
Correct |
10 ms |
344 KB |
Output is correct |
10 |
Correct |
13 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2059 ms |
2928 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |