304 North Cardinal St.
Dorchester Center, MA 02124

# Chef and Filters CodeChef Solution

## Chef and Filters CodeChef Solution in C++14

``````#ifdef F
#include "dandan.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...)
#endif
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define w(x) int x; cin >> x; while(x--)
#define forn(i, n) for(int i = 0; i < (n); ++i)
#define int long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define ff first
#define ss second
#define pb push_back
#define endl '\n'

vector<int> basis;
int siz;
{
forn(i, 10)
{
if (!(mask & (1ll << i)))
continue;
if (!basis[i])
{
++siz;
return;
}
}
}
const int MOD = 1e9 + 7;
int bpow(int a, int b, int m = MOD)
{
a %= m;
int res = 1;
while (b > 0)
{
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}

{
forn(i, 10)
{
if (!(mask & (1ll << i)))
continue;
if (!basis[i])
return 0;
}
return 1;
}

int32_t main()
{
FIO
w(T)
{
siz = 0;
basis.assign(10, 0);

int n;
string s;
cin >> s >> n;
int x = 0;
forn(i, 10)
if (s[i] == 'w')
x |= (1ll << i);
forn(i, n)
{
string f;
cin >> f;
int tt = 0;
forn(j, 10)
if (f[j] == '+')
tt |= (1ll << j);
ins(tt);
}
if (check(x))
cout << bpow(2, n - siz) << endl;
else
cout << 0 << endl;
}
return 0;
}``````

## Chef and Filters CodeChef Solution in PYTH 3

``````mod = 10**9+7
N = 10**5
p2 = [1]*(N+1)
for i in range(N): p2[i+1] = (p2[i] << 1) % mod
ans = 0; mask = 1
for i in range(9,-1,-1):
if s[i]=='w' or s[i]=='+':
return ans
val = 1<<10
for _ in range(int(input())):
s = input()
n = int(input())
cnt = [0]*(val)
for i in range(n):
fil = input()
pre = [0]*val; pre[0]=1
for i in range(val):
if cnt[i]:
cur=[0]*(val)
for j in range(val):
cur[j] = ((pre[j]+pre[i^j])*p2[cnt[i]-1])%mod
pre=cur

## Chef and Filters CodeChef Solution in C

``````#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#ifndef ONLINE_JUDGE
#define gc getchar
#else
#define gc getchar_unlocked
#endif

typedef unsigned long long ull;

int dp[1024][1024];

int main(){
int ans,max,j,i,t,n,p,carr,*power;
char c;
ull temp,temp2,temp3;
power = (int*)calloc(100010,sizeof(int));
power[0] = 1;
for(i = 1;i<=100000;i++){
temp = 2*power[i-1];
if(temp>=1000000007)
temp-=1000000007;
power[i] = temp;

//printf("%d\n",power[i]);
}
scanf("%d",&t);
//printf("%d\n",t);
getchar();
while(t--){
max = 0;
//char C[10];
int *filter;
filter = (int*)calloc(1026,sizeof(int));
p = 0;

for(i = 0;i<10;i++){
c = gc();
if(c == 'b')
p+=power[10-(i+1)];
}
scanf("%d",&n);
getchar();
for(i = 0;i<n;i++){
temp = 0;
for(j = 0;j<10;j++){
c = gc();
if(c == '+')
temp+=power[10-(j+1)];
}

gc();
if(max<temp)
//puts("yes");
max = temp;
//printf("temp--%d max---%d\n",temp,max);
filter[temp]++;
}
for(j = 0;j<1024;j++){
dp[0][j] = 0;
}
dp[0][p] = power[filter[0]];

for(i = 1;i<1024;i++){
if(i > max)
break;
for(j = 0;j<1024;j++){

if(filter[i]>0){
temp2 = (ull)dp[i-1][j]+(ull)dp[i-1][i^j];
if(temp2>1000000007)
temp2-=1000000007;
//temp2 =
temp3 = (ull)power[filter[i]-1];
temp = (ull)temp2*(ull)temp3;
}
else temp = dp[i-1][j];
if(temp>=1000000007)
temp=temp%1000000007;

dp[i][j] = temp;
}
}

printf("%d\n",dp[max][1023]);

free((void*)filter);
}
free((void*)power);
return 0;

}
``````

## Chef and Filters CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;

class a_xor {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

int mod=1000000007;

OutputWriter out=new OutputWriter(System.out);

long power2[]=new long[111111];
power2[0]=1;

for(int i=1;i<111111;i++){
power2[i]=(2*power2[i-1])%mod;
}

while(t>0){
long array[][]=new long[1024][1024];

long k=0;

for(int i=0;i<=9;i++){

if(s.charAt(i)=='w'){
k=k+power2[9-i]*1;
}

else{
k=k+power2[9-i]*0;
}
}
int aa[]=new int[1024];

for(int j=0;j<n;j++){
long g=0;

for(int i=0;i<=9;i++){

if(s.charAt(i)=='-'){
g=g+power2[9-i]*0;
}

else{
g=g+power2[9-i]*1;
}
}

aa[(int)g]++;
}

array[0][0]=power2[aa[0]];

for(int i=1;i<1024;i++){

for(int j=0;j<1024;j++){
if(aa[i]!=0){

array[i][j]=(array[i][j]+power2[aa[i]-1]*array[i-1][j])%mod;
array[i][j^i]=(array[i][j^i]+power2[aa[i]-1]*array[i-1][j])%mod;
}

else{
array[i][j]=array[i-1][j];
}
}
}

out.printLine(array[1023][(int)k]);

t--;
}

out.close();

}

}

private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;

this.stream = stream;
}

if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}

while (isSpaceChar(c))
int sgn = 1;
if (c == '-') {
sgn = -1;
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
} while (!isSpaceChar(c));
return res * sgn;
}

while (isSpaceChar(c))
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
} while (!isSpaceChar(c));
return res.toString();
}

public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

public String next() {
}

public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
class OutputWriter {
private final PrintWriter writer;

public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}

public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}

public void print(Object...objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0)
writer.print(' ');
writer.print(objects[i]);
}
}

public void printLine(Object...objects) {
print(objects);
writer.println();
}

public void close() {
writer.close();
}

public void flush() {
writer.flush();
}

}

class IOUtils {
int[] array = new int[size];
for (int i = 0; i < size; i++)
return array;
}

}``````

## Chef and Filters CodeChef Solution in PYTH

``````for t in range(input()):
s=raw_input()

s1=0

for i in range(len(s)):
if s[i]=='w':
s1+=1<<i
c=[0]*(1<<10)
for i in range(input()):
s2=0
x=raw_input()
for j in range(len(x)):
if x[j]=='+':
s2+=1<<j
c[s2]+=1
v=[0]*(1<<10)
v[0]=1
for i in range(1<<10):
if c[i]:
for j in range(1<<10):

if j<=(j^i):
v[j^i]=((v[j]+v[j^i])*pow(2,c[i]-1,1000000007))%1000000007
v[j]=v[j^i]
print v[s1]
``````

## Chef and Filters CodeChef Solution in C#

``````using System;

class Sol
{
static void Main()
{
for (int m = 0; m < t; m++)
{

bool[] w = new bool[10];
int[] basis = new int[100005];
int bn = 0, zeroes = 0;
int MOD = 1000000007;
for (int k = 0; k < n; k++)
{
for (int j = 0; j < bn; j++)
++zeroes;
else

}
int ans = 0;
for (int i = 0; i < (1 << bn); i++)
{
int q = 0;
for (int j = 0; j < bn; j++)
if ((i & (1 << j))!=0)
q = q ^ basis[j];
if (q == x)
++ans;
}
for (int i = 0; i < zeroes; i++)
ans = (ans * 2) % MOD;
Console.WriteLine(ans);
}
}

{
int ret = 0;
for (int i = 0; i < s.Length; i++)
if (s[i] == '+' || s[i] == 'w')
ret += (1 << i);
return ret;
}

}``````
##### Chef and Filters CodeChef Solution Review:

In our experience, we suggest you solve this Chef and Filters CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Chef and Filters CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Chef and Filters CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!