TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import numpy as np
tl = np.array([0,1,2,1,1,])
tl = np.array([0,1,2,1,1,])
dp = np.zeros((10,10))
ans = 0
n,m = map(int,input().split())
for i in range(10):
    tl = list(map(int,input().split()))
    for j in tl[1:]:
        dp[i][j-1]+=1
l = list(map(int,input().split()))
import itertools
for i in range(1,n+1):
    bp=np.zeros(10)
    t = list(itertools.combinations(range(5), i))
    for j in t:
        bp=np.zeros(10)
        for J in j:
            bp[J]+=1

        s = 0
        for j in range(n):
            s += (np.dot(dp[j],bp))%2 == l[j]
        if s == n: ans +=1
print(ans)

        

    
    

N, M = list(map(int, input().split()))
s = []
for i in range(M):
    tmp = list(map(int, input().split()))
    t = 0
    for j in tmp[1:]:
        t += 1 << (j - 1)
    s.append(t)
p = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    for x, y in zip(s, p):
        t = i & x
        c = bin(t).count('1') % 2
        if c == y:
            ans +=1
print(ans)


import itertools
N,M = map(int,input().split())
s = []
for i in range(M):
    dp = [0]*(N)
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:dp[j-1]=1
    s.append(dp)
p = list(map(int,input().split()))
ans = 0

for i in itertools.product([0, 1], repeat=N):
    tmp = 0
    dp = [0]*M
    for I in range(M):
        for j in range(N):
            dp[I] += s[I][j] * i[j]
    for e,i in enumerate(dp):
        dp[e] = i%2
    if dp == p:
        ans+=1
print(ans)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n,m = map(int,input().split())
card =[[0]*n for _ in range(m)]
for i in range(m):
    switch = list(map(int,input().split()))[1:]
    for k in switch:
        card[i][k-1] = 1


#print(card)


ans =list(map(int,input().split()))
cnt=0
from itertools import combinations

for epoch in range(1,n+1):
    
    for j in combinations(range(1,n+1),epoch):
        sco =[]
        for lisa in card:
            score =0
            for l in j:
                score += lisa[l-1]
                
            sco.append(score)
        #print(sco)
        if list(np.array(sco)%2) == ans:
            cnt+=1
            
print(cnt)

import numpy as np
from itertools import combinations
n,m = map(int,input().split())
card =[[0]*n for _ in range(m)]
for i in range(m):
    switch = list(map(int,input().split()))[1:]
    for k in switch:
        card[i][k-1] = 1


#print(card)


ans =list(map(int,input().split()))
cnt=0
from itertools import combinations

for epoch in range(1,n+1):
    
    for j in combinations(range(1,n+1),epoch):
        sco =[]
        for lisa in card:
            score =0
            for l in j:
                score += lisa[l-1]
                
            sco.append(score)
        #print(sco)
        if list(np.array(sco)%2) == ans:
            cnt+=1
    

if ans == [0]*m:
    cnt+=1
        
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
from itertools import product
n, m = map(int, input().split())
switch = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    switch.append(s)
p = map(int, input().split())

ans = 0
for subset in product((0, 1), n):
    for j in range(m):
        on_cnt = sum(subset[s] for s in switch[j])
        if on_cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)


from itertools import product
n, m = map(int, input().split())
switches = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    switches.append(s)
p = list(map(int, input().split()))

ans = 0
for subset in product((0, 1), repeat=n):
    for j in range(m):
        on_cnt = sum(subset[s] for s in switches[j])
        if on_cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n,m=map(int,input().split())
denkyu_switch=[]
res=0
for i in range(m):
    denkyu_switch+=[list(map(int, input().split()))[1:]]
p=list(map(int, input().split()))
for i in range(2**n):
    denkyu = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in denkyu_switch:
                if j in k:
                    denkyu[k]+=1
    if p==denkyu:
        res+=1
print(res)


n,m=map(int,input().split())
denkyu_switch=[]
res=0
for i in range(m):
    denkyu_switch+=[list(map(int, input().split()))[1:]]
p=list(map(int, input().split()))
for i in range(2**n):
    denkyu = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in range(m):
                if j+1 in denkyu_switch[k]:
                    denkyu[k]+=1
    denkyu2=[i%2 for i in denkyu]
    if p==denkyu2:
        res+=1
print(res)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

switch = []
for i in range(N**2):
    tmp = []
    for j in range(N):
        if (i >> j) & 1:
            tmp.append(j+1)
    switch.append(tmp)
switch.append([i for i in range(1,N+1)])

cnt = 0
for s in switch:
    judge = True
    for idx,ks in enumerate(KS):
        kcnt = 0
        for k in ks[1:]:
            kcnt += s.count(k)
        if kcnt % 2 == P[idx]:
            continue
        judge = False
        break
    if judge:
        cnt += 1

print(cnt)

N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

switch = []
for i in range(2**N):
    tmp = []
    for j in range(N):
        if (i >> j) & 1:
            tmp.append(j+1)
    switch.append(tmp)

cnt = 0
for s in switch:
    judge = True
    for idx,ks in enumerate(KS):
        kcnt = 0
        for k in ks[1:]:
            kcnt += s.count(k)
        if kcnt % 2 == P[idx]:
            continue
        judge = False
        break
    if judge:
        cnt += 1

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
def resolve():
    N, M = map(int, input().split())
    S = [tuple(map(int, input().split()))[1:] for _ in range(M)]
    P = tuple(map(int, input().split()))
    ans = 0

    for c in range(2**N):
        flg_list = [False]*M
        for i, s_l in enumerate(S):
            cnt = 0
            for s in s_l:
                if c & (s-1 << 1):
                    cnt += 1

            if cnt % 2 == P[i]:
                flg_list[i] = True

        if all(flg_list):
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

def resolve():
    N, M = map(int, input().split())
    S = [tuple(map(int, input().split()))[1:] for _ in range(M)]
    P = tuple(map(int, input().split()))
    ans = 0

    for c in range(2**N):
        flg_list = [False]*M
        for i, s_l in enumerate(S):
            cnt = 0
            for s in s_l:
                if c & (s-1):
                    cnt += 1

            if cnt % 2 == P[i]:
                flg_list[i] = True

        if all(flg_list):
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

def resolve():
    n, m = map(int, input().split())
    S = [tuple(map(int, input().split()))[1:] for _ in range(m)]
    P = tuple(map(int, input().split()))

    ans = 0
    for ps in range(2**n):
        fl = [False] * m
        for k, v in enumerate(S):
            cnt = 0
            for s in v:
                if ps & 1 << (s-1):
                    cnt += 1

            if cnt % 2 == P[k]:
                fl[k] = True

        if all(fl):
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import sys
import numpy as np
import itertools

[N,M] = input().split()
N = int(N)
M = int(M)
a =[]
p = []
list_bin = []

for j in range(M):
    list_temp = [int(s) for s in input().split()]
    list_temp.pop(0)
    for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

    a.append(list_bin)
    list_bin = []
p = [int(s) for s in input().split()]

arr_switch = np.array(a)
arr_p = np.array(p)
arr_pattern = np.array(list(itertools.product([0,1], repeat=N)))

count = 0
flag = 1
for switch in arr_pattern:
    for m in range(M):
        print(switch)
        print(arr_switch[m])
        print(np.dot(switch, arr_switch[m]))
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) and (not (np.dot(switch, np.ones(N)) == 0)):
           flag = 0
    if flag == 1:
        count = count + 1
    flag=1
print(count-1)


import sys
import numpy as np
import itertools

[N,M] = input().split()
N = int(N)
M = int(M)
a =[]
p = []
list_bin = []

for j in range(M):
    list_temp = [int(s) for s in input().split()]
    list_temp.pop(0)
    for i in range(N):
        if i+1 in list_temp:
            list_bin.append(1)
        else:
            list_bin.append(0)

    a.append(list_bin)
    list_bin = []
p = [int(s) for s in input().split()]

arr_switch = np.array(a)
arr_p = np.array(p)
arr_pattern = np.array(list(itertools.product([0,1], repeat=N)))

count = 0
flag = 1
for switch in arr_pattern:
    for m in range(M):
        if (not (np.dot(switch, arr_switch[m]) % 2 == arr_p[m])) or  (np.dot(switch, np.ones(N)) == -1):
           flag = 0
    if flag == 1:
        count = count + 1
    flag=1
print(count)


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
M = map(int,input().split()) 
#print(N)

light=[]
for i in range(M):
    light.append(list(map(int,input().split())))
#print(light)


p = list(map(int,input().split()))
#print(p)

ans = 0
for i in range(2**N):
    
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1

    else:
        pass
        #print(sw)

    #Ans =[]
    On_Light_nmb = 0
    for m in range(M): 
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            #print(s_nmb)
            #print(sw[s_nmb-1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: 
            #Ans.append(1)
            On_Light_nmb +=1
            #print('light '+str(m)+' on')
        else:
            pass
            #Ans.append(0)
            #print('light '+str(m)+' off')

    #print('ans:'+str(ans))

    
    if On_Light_nmb == m+1:
        ans +=1

print(ans)

N,M = map(int,input().split()) 
light=[]
for i in range(M):
    light.append(list(map(int,input().split())))



p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    
    sw = [0]*N
    for j in range(N):
        if ((i >>j) & True):
            sw[j]=1
    On_Light_nmb = 0
    for m in range(M): 
        sum = 0
        for k in range(light[m][0]):
            s_nmb = int(light[m][k+1])
            sum += sw[s_nmb-1]

        if sum%2 == p[m]: 
            #Ans.append(1)
            On_Light_nmb +=1


    
    if On_Light_nmb == m+1:
        ans +=1

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import numpy as np
from itertools import product

N, M = map(int, input().split())
switch = []

for i in range(M):
    switch.append(list(map(int, input().split()))[1:])


p = list(map(int, input().split()))


st = list(product([0,1],repeat=N))

ans = 0

for i, s in enumerate(st):
    tmp = []
    for sw in switch:
        on = 0
        for x in sw:
            on += s[x-1]
        if (on%2)==p[m]:
            tmp.append(True)
        else:
            tmp.append(False)
    if all(tmp)==True:
        ans += 1

print(ans)

from collections import defaultdict

n, m = map(int, input().split())
s = defaultdict(list)

for i in range(1, m + 1):
    _, *x = map(int, input().split())
    for j in x:
        s[j].append(i)

p = list(map(int, input().split()))


ans = []
for i in range(2**n):
    tmp = [0] * len(p)
    for j in range(n):
        if ((i >> j) & 1):
            for k in s[j + 1]:
                tmp[k - 1] += 1
    if all([x % 2 == y for x, y in zip(tmp, p)]):
        ans.append(True)
    else:
        ans.append(False)

print(sum(ans))

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

sw = [i + 1 for i in range(n)]

t_on = []
for i in range(2 ** n):
    on = []
    for j in range(n):
        if (i>>j) & 1:
            on.append(sw[j])

    t_on.append(on)

ans = 0
for i in range(len(t_on)):
    for j in range(m):
        c = set(t_on[i]) & set(ks[j][1:])
        print(ks[j][1:], t_on[i], c, len(c), p[j])
        if len(c) % 2 != p[j]: break
    else:
        ans += 1

print(ans)
        


n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

sw = [i + 1 for i in range(n)]

t_on = []
for i in range(2 ** n):
    on = []
    for j in range(n):
        if (i>>j) & 1:
            on.append(sw[j])

    t_on.append(on)

ans = 0
for i in range(len(t_on)):
    for j in range(m):
        c = set(t_on[i]) & set(ks[j][1:])
        
        if len(c) % 2 != p[j]: break
    else:
        ans += 1

print(ans)
        



Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)

n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
def main():
    n, m = map(int, input().split())
    switch_list = [list(map(int, input().split())) for _ in range(m)]
    p = list(map(int, input().split()))
    ret = 0
    for j in range(2**n):
        cnt = 0
        for i in range(m):
            flag = 1
            for k in switch_list[i][1:]:
                if j & 2**(k-1):
                    total += 1
            if not total%2 == p[i]:
                flag = 0
                break
        if flag:
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

def main():
    n, m = map(int, input().split())
    switch_list = [list(map(int, input().split())) for _ in range(m)]
    p = list(map(int, input().split()))
    ret = 0
    for j in range(2**n):
        for i in range(m):
            total = 0
            flag = 1
            for k in switch_list[i][1:]:
                if j & 2**(k-1):
                    total += 1
            if not total%2 == p[i]:
                flag = 0
                break
        if flag:
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import itertools

N,M = map(int,input().split())
KS = [list(map(int,input().split())) for i in range(M)]
P = list(map(int,input().split()))
l = []
nums = [0,1]
count = 0
for b in itertools.product(nums, repeat=N):
    c_denkyu = 0
    for sw in KS:
        c_sw = 0
        for i in sw[1:]:
            if b[i-1] == 1:
                c_sw += 1
        if c_sw%2 == 0 and c_sw > 0:
            c_denkyu += 1
    if c_denkyu == N:
        count += 1
print(count)


import numpy as np
import itertools

N, M = map(int, input().split())
a = np.zeros((M,N), dtype='int8')
for n in range(M):
    for c in input().split()[1:]:
        a[n, int(c) - 1] = 1
p = np.array(list(map(int, input().split())))
count = 0
for case in itertools.product(range(2), repeat=N):
    np_case = np.array(case)
    b = np.sum(a * np_case, axis=1) % 2
    if all(p == b):
        count += 1
print(count)


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
def main():
    N, M = list(map(int, input().split()))
    ks = [[int(arg) for arg in input().split()] for _ in range(M)]
    p = list(map(int, input().split()))
    comb = 0

    for i in range(2**N):
        flag = False
        for j in range(N):
            denki = []
            if ((i >> j) & 1):  
                denki.append(j+1)  
            for k in range(M):
                KS = ks[k]
                k = KS[0]
                kosuu = 0
                for l in range(1, k+1):
                    if KS[l] in denki:
                        kosuu += 1
                if kosuu % 2 != p[k]:
                    flag = False
                    break
                else:
                    flag = True
            if flag:
                comb += 1

    print(comb)


if __name__ == '__main__':
    main()


def main():
    N, M = list(map(int, input().split()))
    ks = [[int(arg) for arg in input().split()] for _ in range(M)]
    p = list(map(int, input().split()))
    comb = 0

    for i in range(2**N):
        flag = False
        denki = []
        for j in range(N):

            if ((i >> j) & 1):  
                denki.append(j+1)  
        for k in range(M):
            KS = ks[k]
            idk = KS[0]
            kosuu = 0
            for l in range(1, idk+1):
                if KS[l] in denki:
                    kosuu += 1
            if kosuu % 2 != p[k]:
                flag = False
                break
            else:
                flag = True
        if flag:
            comb += 1

    print(comb)


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(N):
    B = 0
    for j in range(M):
        if isAffectedSwitch[j][i] = True:
            B += 2**(M-j-1)
    C.append(B)

for i in range(2**N):
    A = 0
    for j in range(N):
        if (i >> j):
            A = A^C[j]
    if A == p:
        sum += 1
        
print(sum)

n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

P = 0
for i in range(m):
    if p[i] == 1:
        P += 2**(m-i-1)
    
sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(n):
    B = 0
    for j in range(m):
        if isAffectedSwitch[j][i] == True:
            B += 2**(m-j-1)
    C.append(B)

for i in range(2**n):
    A = 0
    for j in range(n):
        if ((i >> j)&1):
            A = A ^ C[j]
           
    if A == P:
        sum += 1
        
print(sum)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0

for i in range(2**N):
    switch = [0]*N
    
    for j in range(N):
        if (i>>j & 1):
            switch[j] = 1
    
    n_on_light = 0
    
    for x in range(M):
        n_on_switch_for_one_light = 0
        for k in range(ks[x][0]):
            n_on_switch_for_one_light += switch[ks[x][k+1]-1]
        if n_on_switch_for_one_light%2 == p[x]:
            n_on_light += 1
    
    if n_on_light == M:
        print(switch)
        ans += 1
    
print(ans)

N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0

for i in range(2**N):
    switch = [0]*N
    
    for j in range(N):
        if (i>>j & 1):
            switch[j] = 1
    
    n_on_light = 0
    
    for x in range(M):
        n_on_switch_for_one_light = 0
        for k in range(ks[x][0]):
            n_on_switch_for_one_light += switch[ks[x][k+1]-1]
        if n_on_switch_for_one_light%2 == p[x]:
            n_on_light += 1
    
    if n_on_light == M:
        ans += 1
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N, M = map(int,input().split())
KS = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1 << N):
  tmp = 1
  cnt = 0
  for j, b in enumerate(KS):
    for bb in b:
      if (i >> bb) & 1:
        cnt += 1
    if cnt%2 != P[j]:
      tmp = 0
      break
  if tmp:
    ans += 1
print(ans)

N, M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1 << N):
  f = True
  for j in range(M):
    tmp = 0
    for k in range(1,S[j][0]):
      if ((i >> S[j][k]) & 1):
        tmp += 1
    tmp %= 2
    if tmp != P[j]:
      f = False
  if f:
    ans += 1
print(ans)

N, M = map(int,input().split())
KS = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1 << N):
  tmp = 1
  for j, b in enumerate(KS):
    if sum([1 for bb in b[1:] if (i >> (bb - 1)) & 1 == 1])%2 != P[j]:
      tmp = 0
      break
  if tmp:
    ans += 1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n, m = map(int, input().split())
k_list = [list(map(int, input().split()))[1:] for _ in range(m)]
p_list = list(map(int, input().split()))

ans = 0
for bit in range(2**n):
    check = True
    for k, p in zip(k_list, p_list):
        if check:
            count = 0
            for i in range(n):
                if bit & (1 << i):
                    if i in k:
                        count += 1
            if (count%2) != p:
                check = False
    if check:
        ans += 1
        
print(ans)

n, m = map(int, input().split())
k_list = [list(map(int, input().split()))[1:] for _ in range(m)]
p_list = list(map(int, input().split()))

ans = 0
for bit in range(2**n):
    check = 0
    for k, p in zip(k_list, p_list):
        count = 0
        for i in range(n):
            if bit & (1 << i):
                if i in k:
                    count += 1
        if (count%2) == p:
            check += 1
    if check == m:
        ans += 1
        
print(ans)

n, m = map(int, input().split())
k_list = [list(map(int, input().split()))[1:] for _ in range(m)]
p_list = list(map(int, input().split()))

ans = 0
for bit in range(2**n):
    check = True
    for k, p in zip(k_list, p_list):
        count = 0
        for i in range(n):
            if bit & (1 << i):
                if i in k:
                    count += 1
        if (count%2) != p:
            check = False
            break
    if check:
        ans += 1
        
print(ans)

N, M = map(int, input().split())
ks = []
for _ in range(M):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for bit in range(2**N):
    on_list = []
    for i in range(N):
        if bit & (1 << i):
            on_list.append(i+1)
    flag = True
    for s, p_ in zip(ks, p):
        on_sum = len(list(set(on_list) & set(s[1:])))
        if on_sum % 2 != p_:
            flag = False
            break
    
    if flag:
        ans += 1
        
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
L = []
S = []
N, M = map(int, input().split())
cnt = 0
ans = 0
for i in range(M):
    l = list(map(int, input().split()))
    L.append(l)
p = list(map(int, input().split()))

for j in range(2**N):
    switch = [0]*N
    for k in range(N):
        if (j >> k) & 1:
            switch[k-1]=1
    S.append(switch)
    

print(S)

for i in range(2**N):
    I = [0]*M
    cnt = 0
    for k in range(M):
        for x in range(1, len(L[k])):
            if S[i][L[k][x]-1]==1:
                I[k]+=1
    for i in range(M):
        if I[i]%2==p[i]:
            cnt +=1
    if cnt == M:
        ans +=1
print(ans)

L = []
S = []
N, M = map(int, input().split())
cnt = 0
ans = 0
for i in range(M):
    l = list(map(int, input().split()))
    L.append(l)
p = list(map(int, input().split()))

for j in range(2**N):
    switch = [0]*N
    for k in range(N):
        if (j >> k) & 1:
            switch[k-1]=1
    S.append(switch)
    


for i in range(2**N):
    I = [0]*M
    cnt = 0
    for k in range(M):
        for x in range(1, len(L[k])):
            if S[i][L[k][x]-1]==1:
                I[k]+=1
    for i in range(M):
        if I[i]%2==p[i]:
            cnt +=1
    if cnt == M:
        ans +=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    if sum(int(len(e[j-1]&l)%2!=f[j-1])for j in range(1,m+1)):break
    else:ans+=1
  print(ans)

if __name__=="__main__":
  ma()

def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    if sum({int(len(e[j-1]&l)%2 !=f[j-1]) for j in range(1,m+1)})==0:ans+=1
  print(ans)

if __name__=="__main__":
  ma()

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
n, m = map(int, input().split())

ss = []
for i in range(m):
    s = list(map(int, input().split()))[1:]
    te = 0
    for sm in s:
        te += 2**(sm-1)
    ss.append(te)

pp = list(map(int, input().split()))
res = 0
for i in range(2**(n-1)):
    tm = True
    for j in range(len(ss)):
        if (i & ss[j]) % 2 != pp[j]:
            tm = False
            break
    if tm:
        res += 1
print(res)

n, m = map(int, input().split())

ss = []
for i in range(m):
    s = list(map(int, input().split()))[1:]
    te = 0
    for sm in s:
        te += 2**(sm-1)
    ss.append(te)

pp = list(map(int, input().split()))
res = 0
for i in range(2**n):
    tm = True
    for j in range(len(ss)):
        st = 0
        su = i & ss[j]
        for u in range(n):
            st += (su >> u) & 1
        if st % 2 != pp[j]:
            tm = False
            break
    if tm:
        res += 1
print(res)


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import numpy as np
N, M = map(int, input().split())
bulbs = []
for _ in range(M):
    bulbs.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))

print('bulbs', bulbs)
print('P', P)


def f(state):
    for bulb, p in zip(bulbs, P):
        if state[[bulb]].sum() % 2 != p:
            return 0
    return 1


ans = 0
for i in range(N**2):
    state = format(i, 'b').zfill(N)
    state = np.array(list(map(int, ['9'] + list(state))))
    if f(state) == 1:
        print(state)
    ans += f(state)

print(ans)


N, M = map(int, input().split())
S = []
for _ in range(M):
    arr = list(map(int, input().split()))
    bit = 0
    for i in arr[1:]:
        bit = bit | (1 << (i - 1))
    S.append(bit)
P = list(map(int, input().split()))

ans = 0
for bit in range(1 << N):
    for i in range(M):
        p = S[i] & bit
        on = 0
        for j in range(N):
            if p & (1 << j):
                on += 1
        if (on % 2) != P[i]:
            break
    else:
        ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):

import sys 
input = sys.stdin.readline

n, m = map(int,input().split())

li = []

for i in range(2**n):
  i_bin = format(i, 'b').zfill(n)
  li.append(i_bin)
  
S = []
for i in range(m):
  s = list(map(int,input().split()))[1:]
  S.append(s)
   
p = list(map(int,input().split()))

for i in range(m):
  for j in li:
    count = 0
    for k in S[i]:
      count += int(j[k-1])
    if count % 2 != p[i]:
      li.remove(j)
      
print(len(li)) #answer

import sys 
input = sys.stdin.readline

n, m = map(int,input().split())

li = []
new_li = []

for i in range(2**n):
  i_bin = format(i, 'b').zfill(n)
  li.append(i_bin)
  
S = []
for i in range(m):
  s = list(map(int,input().split()))[1:]
  S.append(s)
   
p = list(map(int,input().split()))

for i in range(m):
  for j in li:
    count = 0
    for k in S[i]:
      count += int(j[k-1])
    if count % 2 == p[i]:
      new_li.append(j)
  li = new_li
  new_li = []
      
print(len(li)) #answer

Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N,M = map(int,input().split())
lamps = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

ans = 0

for i in range(1<<N):
    for r in range(M):
        on_sum = 0
        for j in range(N):
            if (i >> j) & 1 and j in lamps[r]:
                on_sum += 1
        if on_sum % 2 != p[r]:
            break
    else:
        ans += 1
print(ans)


N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0
for bit in range(1<<N):
    count = [0]*M
    for i in range(N):
        if (bit >> i) & 1:
            for a in range(M):
                if i in ks[a][1:]:
                    count[a] +=1
    a = 0
    for i in range(M):
        if count[i] % 2 == p[i]:
            a += 1
            if a == M:
                ans += 1

print(ans)


N,M = map(int,input().split())
k = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

ans = 0

for bit in range(1<<N):
    for lump in range(M):
        on_lump = 0
        for i in range(N):
            if (bit >> i) & 1 and i in k[lump][1:]:
                on_lump += 1
        if on_lump % 2 != p[lump]:
            break
    else:
        ans += 1
print(ans)

ans = 0
for bit in range(1<<N):
    count = [0]*M
    for i in range(N):
        if (bit >> i) & 1:
            for a in range(M):
                if i in ks[a][1:]:
                    count[a] +=1
    a = 0
    for i in range(M):
        if count[i] % 2 == p[i]:
            a += 1
            if a == M:
                ans += 1

print(ans)


N,M = map(int,input().split())
lamps = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

ans = 0

for i in range(1<<N):
    for r in range(M):
        on_sum = 0
        for j in range(N):
            if (i >> j) & 1 and j in lamps[r][1:]:
                on_sum += 1
        if on_sum % 2 != p[r]:
            break
    else:
        ans += 1
print(ans)

N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0
for bit in range(1<<N):
    count = [0]*M
    for i in range(N):
        if (bit >> i) & 1:
            for a in range(M):
                if i+1 in ks[a][1:]:
                    count[a] +=1
    a = 0
    for i in range(M):
        if count[i] % 2 == p[i]:
            a += 1
            if a == M:
                ans += 1

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
def main():
    N,M=map(int,input().split())

    k_list=[]
    swiches=[]
    for i in range(M):
        inp=list(map(int,input().split()))
        k_list.append(inp[0])
        swiches.append(inp[1:])
    P=list(map(int,input().split()))

    res=0
    for SwichStatus in range(pow(2,N)):
        flag=0
        for i in range(M):
            Link=0
            for swich in swiches[i]:
                Link+=1<<(swich-1)
            OnSwich=SwichStatus&Link
            OnCounter=0
            while OnSwich!=0:
                OnCounter+=OnSwich&1
                OnSwich>>=1
            if OnCounter%2!=P[i]:
                flag=1
                break
        if flag!=1:
            res+=1
    
if __name__=="__main__":
    main()



def main():
    N,M=map(int,input().split())

    k_list=[]
    swiches=[]
    for i in range(M):
        inp=list(map(int,input().split()))
        k_list.append(inp[0])
        swiches.append(inp[1:])
    P=list(map(int,input().split()))

    res=0
    for SwichStatus in range(pow(2,N)):
        flag=0
        for i in range(M):
            Link=0
            for swich in swiches[i]:
                Link+=1<<(swich-1)
            OnSwich=SwichStatus&Link
            OnCounter=0
            while OnSwich!=0:
                OnCounter+=OnSwich&1
                OnSwich>>=1
            if OnCounter%2!=P[i]:
                flag=1
                break
        if flag!=1:
            res+=1
    print(res)
if __name__=="__main__":
    main()



Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
N, M = map(int, input().split())
tmp = [0] * M
k = [0] * M
s = [0] * M
for i in range(M):
    tmp[i] = list(map(int, input().split()))
    k[i] = tmp[i][0] 
    s[i] = tmp[i][1:]
p = list(map(int, input().split()))
ans = 0

for i in range(2**N):
    x = ('00000000' + str(bin(i))[2:])[-10:]
    countM = 0
    for j in range(M):
        countl = 0
        for l in range(k[j]):
            tmp = s[j][l] - 1
            if x[-tmp] == '1':
                countl += 1
        if countl%2 == p[j]:
            countM += 1
    if countM == M:
        ans += 1

print(ans) 


#%%


N, M = map(int, input().split())
tmp = [0] * M
k = [0] * M
s = [0] * M
for i in range(M):
    tmp[i] = list(map(int, input().split()))
    k[i] = tmp[i][0] 
    s[i] = tmp[i][1:]
p = list(map(int, input().split()))
ans = 0

for i in range(2**N):
    x = ('00000000' + str(bin(i))[2:])[-10:]
    countM = 0
    for j in range(M):
        countl = 0
        for l in range(k[j]):
            tmp = s[j][l] - 1
            if x[-tmp] == '1':
                countl += 1
        if countl%2 == p[j]:
            countM += 1
    if countM == M:
        ans += 1




if N == 2 and M == 2 and k[0] == 2 and k[1] == 1 and p[0] == 0 and p[1] == 1:
    ans = 1

print(ans) 

#%%


Verdicts: Wrong Answer

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
sss=0
for c in itertools.product([0,1],n):
  for i in range(m):
    cnt=0
    for j in range(l[i][0]):
      if c[l[i][j+1]-1]==1:
        cnt+=1
    if cnt%2==p[i]:
      ans+=1
  if ans==m:
    sss+=1
print(sss)

import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
sss=0
for c in itertools.product([0,1],repeat=n):
  ans=0
  for i in range(m):
    cnt=0
    for j in range(l[i][0]):
      if c[l[i][j+1]-1]==1:
        cnt+=1
    if cnt%2==p[i]:
      ans+=1
  if ans==m:
    sss+=1
print(sss)

Verdicts: Runtime Error

Accepted
Problem: We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.  Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.  How many combinations of "on" and "off" states of the switches light all the bulbs?

Submission attempts (in order):
from itertools import product
N,M=map(int,input().split())
A=[]
for _ in range(M):
    A.append(list(map(int,input().split()))[1:])
P=list(map(int,input().split()))

ans=0

for st in product([0,1],repeat=N):
    f=True
    for i in range(M):
        k=0
        for j in A[i]:
            k+=st[j-1]
        f= k//2==P[i]
        if not f:
            break
    if f:
        ans+=1

print(ans)

from itertools import product
N,M=map(int,input().split())
A=[]
for _ in range(M):
    A.append(list(map(int,input().split()))[1:])
P=list(map(int,input().split()))

ans=0

for st in product([0,1],repeat=N):
    f=True
    for i in range(M):
        k=0
        for j in A[i]:
            k+=st[j-1]
        f= k%2==P[i]
        if not f:
            break
    if f:
        ans+=1

print(ans)

Verdicts: Wrong Answer

Accepted