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):
for x in range(2 ** N + 1):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

print(ans)

import numpy as np

N, M = map(int, input().split())

ks_list = []
for i in range(M):
    ks = list(map(int, input().split()))
    ks_list.append(ks)
    
p = list(map(int, input().split()))
ans = 0

for x in range(2 ** N):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

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())
lamps = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
p = [int(i) for i in range(m)]
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()
print(ans)


from numpy import *

n, m = map(int, input().split())
l = []
for _ in range(m):
   *a, = map(int, input().split())
   l.append(a[1:])
*p, = map(int, input().split())

ans = 0
for t in range(2**n):
   tmp = array([t >> s & 1 for s in range(n)])
   if p == [sum(tmp[array(i)-1]) % 2 for i in l]:
      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())
k = []
for i in range(N):
    tmp = map(int, input().split())
    k.append(tmp)

p = input().split()

onoff = [0, 1]
kouho = list(itertools.product(onoff, repeat=N))

ans = 0
for li in kouho:
    for i in range(N):
        if p[i] == 0:
            li[i].count(0) % 2 == 0
            ans += 1
        else:
            li[i].count(0) % 2 == 1
            ans += 1
print(ans)

import itertools

N, M = map(int, input().split())
k = []
for i in range(M):
    tmp = [int(j) for j in input().split()]
    k.append(tmp)

p = [int(i) for i in input().split()]

onoff = [0, 1]
kouho = list(itertools.product(onoff, repeat=N))

ans = 0
for li in kouho:
    flag = True
    for i in range(M):
        end = k[i][0]+1
        sum = 0
        for j in range(1, end):
            sum += li[k[i][j]-1]
        if sum % 2 != p[i]:
            flag = False
            break
    if flag == True:
        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())
b=[0]*m
for i in range(m):
  a=list(map(int,input().split()))
  b[i]=a
p=list(map(int,input().split()))
z=0
for i in range(0,2**n):  
  sl=[int(x) for x in list(str(bin(i+2**n)[2:]))]
  flag=0
  for j in range(m):
    s=0
    for l in range(1,b[j][0]):
      s=s+sl[b[j][l]]
    if s%2!=p[j]:
      flag=1
  if flag==0:
    z=z+1
print(z)

n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
c=0
for _ in range(2**n):
  s=format(_,'0{}b'.format(n))
  f=1
  for i in range(m):
    a=0
    for j in range(1,k[i][0]+1):
      a+=int(s[k[i][j]-1])
    if a%2!=p[i]:
      f=0
      break
  if f:
    c+=1
print(c)

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 = (int(_) for _ in input().split())  
skp = [[int(i) for i in input().split()] for i in range(m+1)]
sk, p = skp[:-1], skp[-1]

def judge(sw_status, sk, p):
  sk = np.array(sk) - 1
  num = sw_status[sk[1:]].sum()%2
  if num == p:
    light = 1
  else:
    light = 0
  return light


ans = 0
for i in range(2**n):
  sw_status = [j for j in bin(i)][2:]
  for SK, P in zip(sk, p):
  	j = judge(sw_status, SK, P)
    if j==0:
      break
    else:
      ans += 1

print(ans)

import numpy as np
n, m = (int(_) for _ in input().split())  
skp = [[int(i) for i in input().split()] for i in range(m+1)]
sk, p = skp[:-1], skp[-1]

def judge(sw_status, sk, p):
    sk = (np.array(sk) - 1).tolist()
    num = sw_status[[sk[1:]]].sum()%2
    if num == p:
        light = 1
    else:
        light = 0
    return light

ans = 0
for i in range(2**n):
    sw_status = np.array([j for j in bin(i)[2:].zfill(n)]).astype(int)
    for SK, P in zip(sk, p):
        j = judge(sw_status, SK, P)
        if j is 0:
            break
    if j is 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):
s = []
for i in range(m):
  st = list(map(int, input().split()))
  s.append(st[1 :])
  p = list(map(int, input().split()))

  ans = 0
  
  for i in range(1 << n):
    al = True
    
    v = [bool(i & (1 << x)) for x in range(n)]
    
    for j in range(m):
      
      num = 0
      
      for t in s[j]:
        num += v[t - 1]
        if p[j] != num % 2:
          al = False
          ans += al
          print(ans)   

n, m = map(int, input().split())
s = []
for i in range(m):
    st = list(map(int, input().split()))
    s.append(st[1 :])
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    al = True
    
    v = [bool(i & (1 << x)) for x in range(n)]
    
    for j in range(m):
        
        num = 0
        
        for t in s[j]:
            num += v[t - 1]
        if p[j] != num % 2:
            al = False
    ans += al
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())
k=[0]*m
s=[set() for i in range(m)]
for i in range(m):
  k[i],*t=map(int,input().split())
  for j in range(k[i]):
    s[i].add(t[j])
ans=0
p=list(map(int,input().split()))
for i in range(2**n):
  switch=[0]*n
  flag=True
  for j in range(n):
    if i>>j&1:
      switch[j]=1
  for j in range(m):
    on_cnt=0
    for k in range(n):
      if switch[k]==1 and k in s[j]:
        on_cnt+=1
    if on_cnt%2!=p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

n,m=map(int,input().split())
k=[0]*m
s=[set() for i in range(m)]
for i in range(m):
  k[i],*t=map(int,input().split())
  for j in range(k[i]):
    s[i].add(t[j]-1)
ans=0
p=list(map(int,input().split()))
for i in range(2**n):
  switch=[0]*n
  flag=True
  for j in range(n):
    if i>>j&1:
      switch[j]=1
  for j in range(m):
    on_cnt=0
    for k in range(n):
      if switch[k]==1 and k in s[j]:
        on_cnt+=1
    if on_cnt%2!=p[j]:
      flag=False
      break
  if flag:
    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())
l=[]
for i in range(M):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**N):
    tmp=[(t>>s)&1 for s in range(N)]
    light=True
    for i in range(M):
        cnt=0
        for j in range(len(l[i])):
            if tmp[l[i][j]-1]=='1':
                cnt+=1
            if cnt%2!=p[i]%2:
                light=False
                break
    if light:
        ans+=1

print(ans)

N,M=map(int,input().split())
l=[]
for i in range(M):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**N):
    tmp=[(t>>s)&1 for s in range(N)]
    print(tmp)
    light=True
    for i in range(M):
        cnt=0
        for j in range(len(l[i])):
            if tmp[l[i][j]-1]==1:
                cnt+=1
                print(cnt)
        if cnt%2 != p[i]%2:
            light=False
    if light:
        ans+=1

print(ans)

N,M=map(int,input().split())
l=[]
for i in range(M):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**N):
    tmp=[(t>>s)&1 for s in range(N)]
    light=True
    for i in range(M):
        cnt=0
        for j in range(len(l[i])):
            if tmp[l[i][j]-1]==1:
                cnt+=1
        if cnt%2 != p[i]%2:
            light=False
    if light:
        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):
import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        p = pm[li]
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        ans += 1
print(ans)


import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        if not isOk:
            break
        p = int(pm[li])
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        print("light_sum{0}:{1}".format(li, light_sum))
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        ans += 1
print(ans)


import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        if not isOk:
            break
        p = int(pm[li])
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        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())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(n-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp　

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 
        for k in range(s[i][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
            if cnt%2 != p[j]:
                false += 1 
        if false == 0:
            ans += 1 
print(ans)

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

switch = [['0'], ['1']]

for i in range(N-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp 

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 
        for k in range(s[j][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
        if cnt%2 != p[j]:
            false += 1 
    if false == 0:
        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())
ks = [list(map(int, input().split()))for i in range(M)]
p = list(map(int, input().split()))
cnt = 0
all_on = 1
ans = 0
for i in range(2**N):
    all_on = 1
    bits = "0" + str(N) + "b" 
    sw_line = str(format(i,bits))
    for j in range(M):
        for k in range(1,ks[j][0]+1):
            sw = sw_line[ks[j][k]-1]
            if(sw== "1"):
                cnt += 1
        if(cnt % 2 != p[j]):
            all_on = 0
    if(all_on == 1):
        ans += 1
print(ans)

N,M = map(int,input().split())
ks = [list(map(int, input().split()))for i in range(M)]
p = list(map(int, input().split()))
cnt = 0
all_on = 1
ans = 0
for i in range(2**N):
    all_on = 1
    bits = "0" + str(N) + "b" 
    sw_line = str(format(i,bits))
    for j in range(M):
        for k in range(1,ks[j][0]+1):
            sw = sw_line[ks[j][k]-1]
            if(sw== "1"):
                cnt += 1
        if(cnt % 2 != p[j]):
            all_on = 0
        cnt = 0
    if(all_on == 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):
N,M = map(int,input())
S = []
K = []
for i in range(M):
    s = list(map(int,input().split()))
    k = s.pop(0)
    S.append(s)
    K.append(k)
P = list(map(int,input().split()))
for i in range(2**N):
    sw = [0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j] = 1
    flag = 1
    for m in range(M):
        po = S[m]
        sum = 0
        for k in range(K[m]):
            if sw[po[k]-1] == 1:
                sum = (sum + 1)%2
        if P[m] != sum:
            flag = 0
    if flag == 1:
        ans += 1
print(ans)

N,M = map(int,input().split())
S = []
K = []
for i in range(M):
    s = list(map(int,input().split()))
    k = s.pop(0)
    S.append(s)
    K.append(k)
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)&1:
            sw[j] = 1
    flag = 1
    for m in range(M):
        po = S[m]
        sum = 0
        for k in range(K[m]):
            if sw[po[k]-1] == 1:
                sum = (sum + 1)%2
        if P[m] != sum:
            flag = 0
    if flag == 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):
N, M = map(int, input().split())
K, S = [], []
for _ in range(M):
	k, *s = map(int, input().split())
	K.append(k)
	S.append(list(map(lambda x: x-1, s)))
p = list(map(int, input().split()))
res = 0
for i in range(1<<N):
	flag = True
	for j in range(M):
		cnt = 0
		for k in S[j]:
			if (i >> k) & 1:
				cnt += 1
				print(i, k, cnt)

		if cnt%2 != p[j]:
			flag = False
			
	if flag: res += 1
print(res)


N, M = map(int, input().split())
K, S = [], []
for _ in range(M):
	k, *s = map(int, input().split())
	K.append(k)
	S.append(list(map(lambda x: x-1, s)))
p = list(map(int, input().split()))
res = 0
for i in range(1<<N):
	flag = True
	for j in range(M):
		cnt = 0
		for k in S[j]:
			if (i >> k) & 1:
				cnt += 1
		if cnt%2 != p[j]:
			flag = False
			
	if flag: 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):
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)


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

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s-1):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if 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 = [[int(x) for x in input().split()] for _ in range(M)]
P = list(map(int,input().split()))

bit = (2 << N) - 1
cnt = 0

for i in range(bit):
  switch = [0] * N
  for j in range(N):
    isOn = (i >> j) & 1
    switch[j] = isOn

  ok = True
  for k in range(M):
    t = KS[k][1:]
    for l in t:
      if not isOn:
        ok = False
        break
    if not ok:
      break

  if ok:
    cnt += 1
    
print(cnt)

import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

bit = (1 << N)
cnt = 0

#print(bit)

for i in range(bit):
    switch = [0] * (N+1)
    for j in range(N):
        isOn = (i >> j) & 1
        switch[j + 1] = isOn

    #print(switch[1:])

    ok = True
    for k in range(M):
        t = KS[k][1:]
        c = 0
        for l in t:
            c += switch[l]

        #print(k, c, P[k])

        if c % 2 != P[k]:
            ok = False
            break

    if ok:
        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):
n, m = map(int, input().split())
light = [
    tuple(map(int, input().split())) for i in range(m)
]
light = sorted(light, key=lambda x: x[0])
p = tuple(map(int, input().split()))

ans = 0
for i in range(2**n+1):
    x = str(bin(i))[2:]
    if len(x) < n:
        x = "0" * (n - len(x)) + x
    a = 1
    for j in range(m):
        check = 0
        for k in light[j][1:]:
            if x[k-1] == "1":
                check += 1
        if check % 2 == p[j]:
            pass
        else:
            a = 0
            break
    if a:
        ans += 1
print(ans)


n, m = map(int, input().split())
light = [
    tuple(map(int, input().split())) for i in range(m)
]
p = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    x = str(bin(i))[2:]
    if len(x) < n:
        x = "0" * (n - len(x)) + x
    a = 1
    for j in range(m):
        check = 0
        for k in light[j][1:]:
            if x[k-1] == "1":
                check += 1
        if check % 2 != p[j]:
            a = 0
            break
    if a:
        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
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        print(A)
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        print(ans)
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, x.split()))[1:]  for x in sys.stdin.readlines()]
p = list(map(int, input().split()))
cnt = 0
dfs([])
print(cnt)

import sys
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, sys.stdin.readline().split()))[1:]  for x in range(m)]
p = list(map(int, sys.stdin.readline().split()))
cnt = 0
dfs([])
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):
n,m = map(int,input().split())

klist = []
slist = [list() for _ in range(m)]

for i in range(m):
    k,*s = map(int,input().split())
    klist.append(k)
    slist[i] = s

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

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for l in slist[j]:
            if (i >> (l-1))&1 ==1:
                cnt += 1
        if cnt%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()))

ans = 0
for i in range(2**n):
    flag = True
    for j in range(m):
        cnt = 0
        for k in range(1, len(ks[j])):
            if (i >> (ks[j][k]-1)) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            flag = False
            break
    if flag:
        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=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans = 0

for i in range(2**n):
  ans += 1
  for j in range(len(s)):
    on = 0
    for k in range(s[j][0]):
      on += ((i>>s[j][k+1])%2)
    if(on%2 != p[j]):
      ans -= 1
      break
      
print(ans)

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

for i in range(2**n):
  ans += 1
  for j in range(len(s)):
    on = 0
    for k in range(s[j][0]):
      on += ((i>>(s[j][k+1]-1))%2)
    if(on%2 != p[j]):
      ans -= 1
      break
      
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())
list_Connect=[]
for i in range(M):
    A = list(map(int, input().split()))
    A.pop(0)
    list_Connect.append( A )

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

print ("list_Connect",list_Connect)
print("list_p",list_p)
i = 0



state = []
sum=0

def func(i):
    global sum
    print(state)
    if i == N:
        flag = True
        for i in range(M):
            cnt= 0
            for j in list_Connect[i]:
                cnt += state[j-1]
            if cnt %2 != list_p[i]:
                print("j ",j)
                flag = False
                break
        if flag == True:
           sum+=1
    else:
        state.append(1)
        func(i+1)
        state.pop(-1)
        state.append(0)
        func(i+1)
        state.pop(-1)

    return


func(0)
print ("答えは",sum)

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

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

i = 0



list_func = []
cnt=0

def func(i):
    if (i == N):
        flag = True
        for k in range(M):
            sum = 0
            for j in list_A[k]:
                sum += j
            sum = sum - list_A[k][0]
            if sum %2 != list_p[k]:
                flag = False
        if flag == True:
            cnt+=1
        return
    list_func.append(1)
    func(i+1)
    list_func.pop(-1)

    list_func.append(0)
    func(i+1)
    list_func.pop(-1)

    return


func(0)
print (cnt)

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

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

i = 0



state = []
sum=0

def func(i):
    global sum
    if i == N:
        flag = True
        for i in range(M):
            cnt= 0
            for j in list_Connect[i]:
                cnt += state[j-1]
            if cnt %2 != list_p[i]:
                flag = False
                break
        if flag == True:
           sum+=1
    else:
        state.append(1)
        func(i+1)
        state.pop(-1)
        state.append(0)
        func(i+1)
        state.pop(-1)

    return


func(0)
print (sum)

Verdicts: Wrong Answer

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 = []
swi = []

for i in range(m):
  x = list(map(int,input().split()))
  s.append(x)
p = list(map(int,input().split()))
print(s,p)

for i in range(1,2**n):
  x = format(i, 'b')
  x = x.zfill(n)
  swi.append(x)
#print(swi[-1])

for j in range(m):
  for i in range(len(swi)-1):
    x = 0
    for k in range(s[j][0]):
      x += int(swi[i][s[j][k]-1])
    if x % 2 != p[j]:
      del swi[i]
print(swi)

n,m = map(int,input().split()) 
s = []
sw = []
 
for i in range(m):
  x = list(map(int,input().split()))
  s.append(x)
p = list(map(int,input().split()))
#print(s,p)
 
for i in range(0,2**n): 
  x = format(i, 'b')
  x = x.zfill(n)
  sw.append(x)

ans = []
for x in sw:
  y = 0 
  for i in range(m):
    z = 0 
    if y == 0:
      for j in range(s[i][0]):
        if x[s[i][j+1]-1] == "1":
          z += 1
      if z%2 != p[i]:
        y += 1
  if y == 0:
    ans.append(x)
print(len(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())
    s = [[int(x) for x in input().split()] for _ in range(M)]
    p = [int(x) for x in input().split()]
    count=0
    for i in range(2**N):
        switch=[0]*N
        sw = bin(i)[2:]
        sw=sw[:-1]
        sw = "0"*(N-len(sw))+sw
        #for j in range(N):
            #switch[j] = int(sw[j])
        All=0   
        for j in range(M):
            Sum=0
            for k in s[j]:
                #if switch[k-1]==1:
                if int(sw[k-1])==1:
                    Sum+=1
            if Sum%2 == p[j]:
                All+=1
        if All==M:
            count+=1
    print(count)

main()

def main():
    N,M = map(int, input().split())
    s = [[int(x) for x in input().split()][1:] for _ in range(M)]
    p = [int(x) for x in input().split()]
    count=0
    for i in range(2**N):
        switch=[0]*N
        sw = bin(i)[2:]
        sw = "0"*(N-len(sw))+sw
        #print(sw)
        #for j in range(N):
            #switch[j] = int(sw[j])
        All=0   
        for j in range(M):
            Sum=0
            for k in s[j]:
                #if switch[k-1]==1:
                if int(sw[k-1])==1:
                    Sum+=1
            if Sum%2 == p[j]:
                All+=1
        if All==M:
            count+=1
    print(count)

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):
import numpy as np

N, M = map(int, input().split())
array = np.zeros([M, N])
for i in range(M):
    l = list(map(int, input().split()))
    for j in l[1:]:
        array[i, j-1] = 1
p = np.array(list(map(int, input().split())))
count = 0
for i in range(1<<N):
    array_i = array.copy()
    for j in range(N):
        if i&(j<<0):
            array_i[:, j-1] = 0
    if sum((array_i.sum(1)%2 == p)&(array_i.sum(1)>0))==M:
        count += 1
print(count)

import numpy as np

N, M = map(int, input().split())
array = np.zeros([M, N])
for i in range(M):
    l = list(map(int, input().split()))
    for j in l[1:]:
        array[i, j-1] = 1
p = np.array(list(map(int, input().split())))
count = 0
for i in range(1<<N):
    array_i = array.copy()
    for j in range(N):
        if i&(1<<j):
            array_i[:, j-1] = 0
    if sum(array_i.sum(1)%2 == p)==M:
        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):
n,m = map(int,input().split())

li=[]
for i in (1, m+1):
    s=list(map(int, input().split()))
    s.pop(0)
    li.append(s)

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

def check(g,en):
    stack = ["1", "0"]
    candi = []
    while stack:
        cur = stack.pop()
        if len(cur) == en:
            candi.append(cur)
            continue
        for i in g[len(cur)+1]:
            tmp = cur+i
            stack.append(tmp)
    return candi

g={}
for i in range(0,n+1):
    g[i]=["1", "0"]

ans = 0
print(check(g,n))
for i in check(g,n):
    flag=0
    for j in range(m):
        tmp=0
        for k in range(0,len(li[j])):
            tmp += int(i[li[j][k]-1])
        if tmp % 2  != p[j]:
            flag=1
            break
    if flag==0:
        print(i)
        ans += 1

print(ans)

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

li=[]
for i in range(1, m+1):
    s=list(map(int, input().split()))
    s.pop(0)
    li.append(s)

if m==1:
    p = [int(input())]
else:
    p = list(map(int, input().split()))
#print(li)
#print(p)

def check(g,en):
    stack = ["1", "0"]
    candi = []
    while stack:
        cur = stack.pop()
        if len(cur) == en:
            candi.append(cur)
            continue
        for i in g[len(cur)+1]:
            tmp = cur+i
            stack.append(tmp)
    return candi

g={}
for i in range(0,n+1):
    g[i]=["1", "0"]

ans = 0
#print(check(g,n))
for i in check(g,n):
    flag=0
    for j in range(m):
        tmp=0
        for k in range(0,len(li[j])):
            tmp += int(i[li[j][k]-1])
        if tmp % 2 != p[j]:
            flag=1
            break
    if flag==0:
        #print(i)
        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())
a=[[0 for h in range(n)] for i in range(2**n)]
b=[[0 for i in range(m)] for h in range(2**n)]

for i in range(2**n):
  b=i
  for j in range(n):
    c=b//(2**(n-j-1))
    a[i][j]+=c
    b-=c*(2**(n-j-1))
print(a)

for i in range(m):
  for j in range(2**n):
    lights=list(map(int,input().split()))
    for h in range(len(lights)-1):
      b[j][i]+=a[j][lights[h+1]-1]
check=list(map(int,input().split()))

ans=0
for i in range(2**n):
  flag=0
  for j in range(m):
    if b[i][j]%2!=check[j]:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)

n,m=map(int,input().split())
a=[[0 for h in range(n)] for i in range(2**n)]
b1=[[0 for i in range(m)] for h in range(2**n)]

for i in range(2**n):
  b=i
  for j in range(n):
    c=b//(2**(n-j-1))
    a[i][j]+=c
    b-=c*(2**(n-j-1))

for i in range(m):
  lights=list(map(int,input().split()))
  for j in range(2**n):
    for h in range(len(lights)-1):
      b1[j][i]+=a[j][lights[h+1]-1]
check=list(map(int,input().split()))

ans=0
for i in range(2**n):
  flag=0
  for j in range(m):
    if b1[i][j]%2 != check[j]:
      flag=1
      break
  if flag==0:
    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())
klist = []
swlist = []
ans = 0
for s in range(m):
	k,*sw = list(map(int,input().split()))
	klist.append(k) 
	swlist.append(sw) 
pwlist = list(map(int,input().split())) 

for i in range(2**n):
	check = True
	for lump in range(m):
		cnt = 0
		for j in range(klist[lump]):
			if (i>>swlist[lump][j])&1==1:
				cnt += 1
		if cnt%2 != pwlist[lump]:
			check = False
	if check == True:
		ans += 1
print(ans)

n,m = map(int,input().split())
klist = []
swlist = []
ans = 0
for s in range(m):
	k,*sw = list(map(int,input().split()))
	klist.append(k) 
	swlist.append(sw) 
pwlist = list(map(int,input().split())) 

for i in range(2**n):
	check = True
	for lump in range(m):
		cnt = 0
		for j in range(klist[lump]):
			if (i>>swlist[lump][j]-1)&1==1:
				cnt += 1
		if cnt%2 != pwlist[lump]:
			check = False
	if check == True:
		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 i in range(M)]
p = list(map(int, input().split()))

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)

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

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)


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

ans = 0
for i in range(2**M):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if (i >> k-1)&1 == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)

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

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar+[0]) + dfs(n-1, ar+[1])
arr = []
ans = dfs(N, arr)
print(ans)


Verdicts: Runtime Error

Runtime Error

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):
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  3 14:23:44 2020

@author: liang
"""

N, M = map(int,input().split())
bulbs = [list(map(int,input().split()))[1:] for _ in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    lights = [1 if (i>>j)&1 == 1 else 0 for j in range(N)]
    if all(sum(lights[x-1] for x in bulbs[k])%2 == p[k] for k in range(len(bulbs))):
            ans += 1



print(bulbs)
print(p)
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Fri Apr  3 14:23:44 2020

@author: liang
"""

N, M = map(int,input().split())
bulbs = [list(map(int,input().split()))[1:] for _ in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    lights = [1 if (i>>j)&1 == 1 else 0 for j in range(N)]
    if all(sum(lights[x-1] for x in bulbs[k])%2 == p[k] for k in range(len(bulbs))):
            ans += 1
#print(bulbs)
#print(p)
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())
arr = [list(map(int, input().split())) for i in range(m)]
p = list(map(int,input().split()))
res = 0

for i in range(2**n):
    res+=1
    for j in range(len(arr)):
        on = 0
        for k in range(arr[j][0]):
            on += i>>(arr[j][k+1])
        if (on%2 != p[j]):
            res -=1
            break
print (res)


n, m = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(m)]
p = list(map(int,input().split()))
res = 0

for i in range(2**n):
    res+=1
    for j in range(len(arr)):
        on = 0
        for k in range(arr[j][0]):
            on += (i>>(arr[j][k+1]-1))%2
        if (on%2 != p[j]):
            res -=1
            break
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):
swithCount, lightCount = map(int, input().split())
swithList = [0] * lightCount

for i in range(swithCount):
    connectedLightList = list(map(int, input().split()))
    for lightIndex in range(connectedLightList[1:]):
        lightIndex -= 1
        swithList[i] = swithList[i] | 1 << lightIndex

expectedLightStatusList = list(map(int, input().split()))
expectedLightStatus = 0

for i, eachStatus in enumerate(expectedLightStatusList):
    expectedLightStatus = expectedLightStatus | eachStatus << i

resultCount = 0
for eachSwitchSet in range(1 << swithCount):
    actuallyLightStatus = 0
    for switchIndex in range(swithCount):
        if eachSwitchSet >> switchIndex & 1:
            actuallyLightStatus = actuallyLightStatus ^ swithList[switchIndex]

    if expectedLightStatus == actuallyLightStatus:
        resultCount += 1

print(resultCount)

swithCount, lightCount = map(int, input().split())
swithList = [0] * swithCount

for lightIndex in range(lightCount):
    connectedSwitchList = list(map(int, input().split()))
    for si in connectedSwitchList[1:]:
        switchIndex =  si - 1
        swithList[switchIndex] = swithList[switchIndex] | 1 << lightIndex

expectedLightStatusList = list(map(int, input().split()))
expectedLightStatus = 0

for i, eachStatus in enumerate(expectedLightStatusList):
    expectedLightStatus = expectedLightStatus | eachStatus << i

resultCount = 0
for eachSwitchSet in range(1 << swithCount):
    actuallyLightStatus = 0
    for switchIndex in range(swithCount):
        if eachSwitchSet >> switchIndex & 1:
            actuallyLightStatus = actuallyLightStatus ^ swithList[switchIndex]

    if expectedLightStatus == actuallyLightStatus:
        resultCount += 1

print(resultCount)



Verdicts: Runtime Error

Accepted