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):
N, M = map(int, input().split())
bi_N = [i+1 for i in range(2**N-1)]
ans = 0
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
p = list(map(int, input().split()))
for i in bi_N[::-1]:
  a = format(i,'b')
  a = str(format(a, '0>10'))
  bi_a = [a[i] for i in range(10)]
  for z, (j, k) in enumerate(zip(l,p)):
    x = 0
    o = j[0]
    for y in range(o+1)[1:]:
      print(bi_a[-j[y]])
      x += int(bi_a[-j[y]])
    if x%2 != k:
      break
    if z == M-1:
      ans += 1
print(ans)

N, M = map(int, input().split())
bi_N = [i for i in range(2**N-1)]
ans = 0
for i in bi_N[::-1]:
  print(i)

N, M = map(int, input().split())
bi_N = [i+1 for i in range(2**N-1)]
ans = 0
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
p = list(map(int, input().split()))
for i in bi_N[::-1]:
  a = format(i,'b')
  a = str(format(a, '0>10'))
  bi_a = [a[i] for i in range(10)]
  for z, (j, k) in enumerate(zip(l,p)):
    x = 0
    o = j[0]
    for y in range(o)[1:]:
      x += int(bi_a[-j[y]])
    if x%2 != k:
      break
    if z == M-1:
      ans += 1
print(ans)

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

ans = 0
for i in range(1<<N):
  for j, k in enumerate(S):
    if sum(1 for kj in k if (i>>(kj-1) & 1))%2 != P[j]:
      break
    if j == len(S)-1:
      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):
N, M = map(int, input().split())
KS = []*M
for i in range(M):
  KS[i]= list(map(int, input().split()))
P = list(map(int, input().split()))

ans = 0
for i in range(N**2):
  sl = []
  for j in range(N):
    if (i>>j)&1:
      sl.append(j+1)
  for j in range(M):
    if len(set(KS[j][1:])&set(sl))%2 ==P[j]:
      continue
    else:
      break
  else:
    ans += 1
    
print(ans)
    

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

ans = 0
for i in range(2**N):
  sl = []
  for j in range(N):
    if (i>>j)&1:
      sl.append(j+1)
  for j in range(M):
    if len(set(KS[j][1:])&set(sl))%2 ==P[j]:
      continue
    else:
      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):
import numpy as np
N, M = map(int, input().split())
lamplist = []
for i in range(M):
    A = list(map(int, input().split()))
    lamplist.append(A)
oddeven_ans = list(map(int, input().split()))
print("{}".format(oddeven_ans))
print("{}".format(lamplist))
switch = np.zeros(N)
ans = 0
for j in range(N * N):
    flag = 0
    oddeven = 0
    for k in range(N):
        switch[k] = j % 2
        j //= 2
    print("{}".format(switch))
    for p in range(M):
        for r in range(1, lamplist[p][0]):
            if switch[lamplist[p][r] - 1] == 1:
                oddeven += 1
        if (int(oddeven % 2)) != int(oddeven_ans[p]):
            flag = 1
    if flag == 0:
        ans += 1
        
print("{}".format(ans))


import numpy as np

N, M = map(int, input().split())
lamplist = [0]*M
for i in range(M):
    A = list(map(int, input().split()))
    lamplist[i] = A
oddeven_ans = list(map(int, input().split()))

switch = np.zeros(N)
ans = 0
numofswitch = np.zeros(M)

for s in range(M):
    numofswitch[s] = lamplist[s][0]
    del lamplist[s][0]

for j in range(2 ** N):
    ansflag = 0

    for k in range(N):
        switch[k] = j % 2
        j //= 2
    for p in range(M):
        numofshining = 0
        for r in lamplist[p]:
            if switch[r-1] == 1:
                numofshining += 1

        if numofshining % 2 != oddeven_ans[p]:
            ansflag = 1
    if ansflag == 0:
        ans += 1

print("{}".format(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 = [int(i) for i in input().split()]
k = []
s = []
for i in range(m):
    tmp = [int(i) for i in input().split()]
    k.append(tmp[0])
    s += [tmp[1:]]
p = [int(i) for i in input().split()]
cnt = 0

for b in range(1 << n):
    sw = [0] * n
    for i in range(n):
        if b & (1 << i): sw[i] = 1
    for i in range(m):
        c = 0
        for j in s[i]:
            if sw[j - 1] == 1: c += 1
        if c % 2 == p[i]: break
        cnt += 1
print(cnt)


n, m = [int(i) for i in input().split()]
k = []
s = []
for i in range(m):
    tmp = [int(i) for i in input().split()]
    k.append(tmp[0])
    s += [tmp[1:]]
p = [int(i) for i in input().split()]
cnt0 = 0

for b in range(1 << n):

    sw = [0] * n
    for i in range(n):
        if b & (1 << i): sw[i] = 1

    status = True
    for i in range(m):
        cnt1 = 0
        for j in s[i]:
            if sw[j - 1] == 1: cnt1 += 1
        if cnt1 % 2 != p[i]: status = False
    
    if status: cnt0 += 1

print(cnt0)


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
import os
from itertools import combinations

def file_input():
    f = open('ABC128/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M=map(int, input().split()) #N:switch M:light
    s=[[] for i in range(M)]
    k=[]
    for i in range(M):
        tmp=list(map(int, input().split()))
        k.append(tmp[0])
        s[i]=tmp[1:]
    p=list(map(int, input().split()))

    out=0
    for i in range(N+1):
        for li in combinations(range(N),i):
            # print(li)
            on=0
            for m in range(M):
                tmp=0
                for j in range(k[m]):
                    # print("m:"+str(m)+" k:"+str(j))
                    for c in li:
                        if s[m][j]==c+1:
                            tmp+=1
                if tmp%2==p[m]:
                    on+=1
            if on==M:
                print(li)
                out+=1

    print(out)


if __name__ == '__main__':
    main()


import sys
import os
from itertools import combinations

def file_input():
    f = open('ABC128/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M=map(int, input().split()) #N:switch M:light
    s=[[] for i in range(M)]
    k=[]
    for i in range(M):
        tmp=list(map(int, input().split()))
        k.append(tmp[0])
        s[i]=tmp[1:]
    p=list(map(int, input().split()))

    out=0
    for i in range(N+1):
        for li in combinations(range(N),i):
            # print(li)
            on=0
            for m in range(M):
                tmp=0
                for j in range(k[m]):
                    # print("m:"+str(m)+" k:"+str(j))
                    for c in li:
                        if s[m][j]==c+1:
                            tmp+=1
                if tmp%2==p[m]:
                    on+=1
            if on==M:
                # print(li)
                out+=1

    print(out)


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):
# -*- coding: utf-8 -*-

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

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


# -*- coding: utf-8 -*-

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

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ 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)


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 = [[] for i in range(m)]
for i in range(m):
    t = list(map(int, input().split()))
    a[i] = t[1:]

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    p_ = p[:]
    for j in range(n):
        if not (i & (1<<j)):
            continue
        for k in range(m):
            if j+1 in a[k]:
                p_[k] ^= 1
    ans += (max(p_) == 0):
print(ans)



n, m = map(int, input().split())
a = [[] for i in range(m)]
for i in range(m):
    t = list(map(int, input().split()))
    a[i] = t[1:]

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    p_ = p[:]
    for j in range(n):
        if not (i & (1<<j)):
            continue
        for k in range(m):
            if j+1 in a[k]:
                p_[k] ^= 1
    ans += (max(p_) == 0)
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 add(s,d):
     sum=0
     for i in d[1:]:
          sum+=s[i] 
     return sum

def check(m):
    for i in range(m):
        if add(s, d[i]) % 2 == p[i]:
            pass
        else :
            return -1
    return 1
        
        
d = []
s=[]
inc=0

n, m = (int(x) for x in input().split())
for i in range(m):
    i = [int(i) for i in input().split()] 
    d.append(i)
p = [int(i) for i in input().split()]


for i in range(32):
    x = '{:0>6}'.format(bin(i).split('b')[1])
    s=list(x)
    s= [int(s) for s in s]
    if check(m) == 1:
            inc +=1
    
print(inc)

def add(s,d):
     sum=0
     for i in d[1:]:
          sum+=s[i] 
     return sum

def check(m):
    for i in range(m):
        if add(s, d[i]) % 2 == p[i]:
            pass
        else :
            return -1
    return 1
        
        
d = []
s=[]
inc=0

n, m = (int(x) for x in input().split())
for i in range(m):
    i = [int(i) for i in input().split()] 
    d.append(i)
p = [int(i) for i in input().split()]


for i in range(32):
    x = '{:0>6}'.format(bin(i).split('b')[1])
    s=list(x)
    s= [int(s) for s in s]
    #print(i, l)
    if check(m) == 1:
            inc +=1
    
print(inc)

def add(s,d):
     sum=0
     for i in d[1:]:
          sum+=s[i] 
     return sum

def check(m):
    for i in range(m):
        if add(s, d[i]) % 2 == p[i]:
            pass
        else :
            return -1
    return 1
        
        
d = []
s=[]
inc=0

n, m = (int(x) for x in input().split())
for i in range(m):
    i = [int(i) for i in input().split()] 
    d.append(i)
p = [int(i) for i in input().split()]

r = 2 ** n

for i in range(r):
    x = str(bin(i).split('b')[1]).zfill(n + 1)
    s=list(x)
    s= [int(s) for s in s]
    if check(m) == 1:
            inc +=1
    
print(inc)

Verdicts: 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):
from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product('01',repeat = N):
  on = 0
  bulb = 0
  for j in range(M):
    for k in range(cc[j][0]):
      if i[cc[m][l+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb += 1
  if bulb == M:
    count += 1
print(count)
    
      
  


from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product([0,1],repeat = N):
  bulb = []
  for j in range(M):
    on = 0
    for k in range(cc[j][0]):
      if i[cc[j][k+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb.append(1)
  if sum(bulb) == M:
    count += 1

print(count)

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())
l=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
#  bit=format(i,'011b')
#  bit=list(reversed(format(i,'b')))
  bit=bin(i)
  print(bit)
  
  num=0
  for j in range(m):
    に接続されている各スイッチ
    cnt=0
    for k in range(1,l[j][0]+1):
#      print(l[j][k])
#      if bit[l[j][k]]==1:
#      if (i>>k)&1:
#      print(i,l[j][k])
      if (i>>l[j][k]-1)&1:
        cnt+=1
    print(i,j,cnt)
    if cnt%2==p[j]:
      num+=1
  if num==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()))

cnt=0
for i in range(2**n):
  l=[0 for j in range(n)]
  for j in range(n):
    if (i>>j)&1:
      l[j]=1

  t_cnt0
  for j in range(m):
    on_l=0
    for x in k[j][1:]:
      x-=1
      if l[x]==1:
        on_l+=1
    if on_l%2==p[j]:
      t_cnt+=1

  if t_cnt==m:
    cnt+=1

print(cnt)

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

cnt=0
for i in range(2**n):
  l=[0 for j in range(n)]
  for j in range(n):
    if (i>>j)&1:
      l[j]=1

  t_cnt=0
  for j in range(m):
    on_l=0
    for x in k[j][1:]:
      x-=1
      if l[x]==1:
        on_l+=1
    if on_l%2==p[j]:
      t_cnt+=1

  if t_cnt==m:
    cnt+=1

print(cnt)

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):
import numpy as np
n,m = map(int,input().split())
k_and_s = list(list(map(int,input().split()))for i in range(m))
p = list(map(int,input().split()))
k = []
s = []
p1 = np.array(p)
print("p1 = ",p1,"\n")
for i in range(m):
    k.append(k_and_s[i][0:1][0])
    s.append(k_and_s[i][1:])
switch = np.array([[0 for i in range(m)]for i in range(n)])
for i in range(len(s)):
    for j in range(len(s[i])):
        switch[s[i][j]-1][i] = 1
ans = 0
for s in range(1<<n):
    t = 0
    for i in range(n):
        if s>>i & 1 == 0:
            t ^= switch[i]
            print("t = ",t,"\n")
            if t == p1:
                ans +=1
            
print("\nswitch = ",switch,"\n")
print("m = ",m)
print("n = ",n)
print("k and s = ",k_and_s)
print("k = ",k)
print("s = ",s)
print("p = ",p1)
#print(len(s))
print(ans)

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

for i in range(2**n):
    on = True
    for j in range(m):
        on = bin(s[j]&i)lcount('1')%2 == p[j]
        if not on:
            break
    ans += on
print(ans)

n,m = map(int,input().split())
k_and_s = list(list(map(int,input().split()))for i in range(m))
p = list(map(int,input().split()))

k = []
s = []
switch = list([[0 for i in range(m)]for i in range(n)])
switch_1 = [0 for i in range(n)]
cnt = 0

for i in range(1,len(p)+1):
    if p[i-1] == 1:
        cnt += 2**(m-i)
    if i == m:
        p_1 = cnt

for i in range(m):
    k.append(k_and_s[i][0:1][0])
    s.append(k_and_s[i][1:])

for i in range(len(s)):
    for j in range(len(s[i])):
        switch[s[i][j]-1][i] = 1

for i in range(len(switch)):
    cnt = 0
    for j in range(1,len(switch[i])+1):
        if switch[i][j-1] == 1:
            cnt += 2**(m-j)
        if j == m:
            switch_1[i] = cnt

ans = 0
for i in range(1<<n):
    t = 0
    for j in range(n):
        if i >> j & 1 != 0:
            t ^= switch_1[j]
    if t==p_1:
        ans +=1
print(ans)

Verdicts: 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):
n,m = map(int,input().split())
ss = []
for _ in range(m):
  s = list(map(int,input().split()))[1:]
  ss.append()
ps = list(map(int,input().split()))

def get_bit(i,n):
  res = []
  for i in range(n):
    res.append(i%2)
    i = int(i/2)
  return res[::-1]

ans = 0
for i in range(2**n):
  flags = get_bit(i,n)
  for j in range(m):
    count = 0
    for k in ss[j]:
      count += flags[k-1]
    if count %2 == ps[j]:
      continue
    else:
      break
  else:
    ans += 1
print(ans)

n,m = map(int,input().split())
ss = []
for _ in range(m):
  s = list(map(int,input().split()))[1:]
  ss.append(s)
ps = list(map(int,input().split()))

def get_bit(i,n):
  res = []
  for _ in range(n):
    res.append(i%2)
    i = int(i/2)
  return res[::-1]

ans = 0
for i in range(2**n):
  flags = get_bit(i,n)
  for j in range(m):
    count = 0
    for k in ss[j]:
      count += flags[k-1]
    if count %2 == ps[j]:
      continue
    else:
      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())
A = []
for _ in range(M):
    A.append(tuple(map(int, input().split())))
P = tuple(map(int, input().split()))
import itertools
def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True
ans = 0
for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1
if hantei(A, 0, P):
    ans += 1
print(ans)

N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(tuple(map(int, input().split())))
P = tuple(map(int, input().split()))
import itertools
def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True
ans = 0
for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1
if hantei(A, [0], P):
    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 _ in range(M)]
p=list(map(int,input().split()))
ans=0
for s in range(1<<N):
    for j in range(M):
        cnt=0
        for h in ks[j][1:]:
            h-=1
            if (s>>h)&1:
                cnt+=1
                cnt%=2
        if cnt!=ks[j][0]:
            break
    else:
        ans+=1
print(ans)

N,M=map(int,input().split())
ks=[list(map(int,input())) for _ in range(M)]
p=list(map(int,input().split()))
ans=0
for s in range(1<<M):
    for j in range(M):
        cnt=0
        for h in ks[j][1:]:
            h-=1
            if (s>>h)&1:
                cnt+=1
                cnt%=2
        if cnt!=ks[j][0]:
            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 s in range(1<<M):
    for j in range(M):
        cnt=0
        for h in ks[j][1:]:
            h-=1
            if (s>>h)&1:
                cnt+=1
                cnt%=2
        if cnt!=ks[j][0]:
            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 s in range(1<<N):
    for j in range(M):
        cnt=0
        for h in ks[j][1:]:
            h-=1
            if (s>>h)&1:
                cnt+=1
                cnt%=2
        if cnt!=p[j]:
            break
    else:
        ans+=1
print(ans)


Verdicts: 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):
n,m = map(int,input().split())
ls = []
for _ in range(m):
  tmp = list(map(int,input().split()))[1:]
  lls = []
  for i in range(1,n+1):
    lls += [int(i in tmp)]
  ls += [lls]
p = list(map(int,input().split()))
count = 0
yyy = [0]*n
while True:
  if yyy[-1] == 2:
    break
  for mi in range(m):
    dd = 0
    for ni in range(n):
      c = 0
      c += ls[mi][ni] * yyy[ni]
      d = c%2
      dd += 1-int(d==p[mi])
  if dd == 0:
    count += 1
  yyy[0] += 1
  for j in range(0,n-1):
    if yyy[j] == 2:
      yyy[j] = 0
      yyy[j+1] += 1
print(count)

while True:
  must1 = 1
  for mi in range(m):
    onoff = 0
    for ni in range(n):
      onoff += li[mi][ni]*yyy[ni]
    should1 = bool(onoff%2 == p[mi])
    must1 *= should1
  if must1 == 1:
    score += 1
  yyy[0] += 1
  for ni in range(n-1):
    if yyy[ni] == 2:
      yyy[ni] = 0
      yyy[ni+1] += 1
  if yyy[n-1] == 2:
    break
print(score)

n,m = map(int,input().split())
time = [0 for _ in range(n)]
def nex(time):
  for i in range(n):
    if time[i] == 0:
      time[i] += 1
      break
    else:
      time[i] = 0
  else:
    time = 'over'
  return time
s = []
for _ in range(m):
  raw = list(map(int,input().split()))
  add = [0 for _ in range(n)]
  for j in range(1,raw[0]+1):
    add[raw[j]-1] = 1
  s.append(add)
p = list(map(int,input().split()))
ans = 0
while time != 'over':
  for k in range(m):
    tmp = p[k]
    for i in range(n):
      tmp ^= time[i] * s[k][i]
    if tmp == 1:
      break
  else:
    ans += 1
  time = nex(time)
print(ans)

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())
mod = 10**9+7
fram = [1]
for i in range(1,N+1):
  fram.append(fram[-1]*i%mod)

#def framod(n, mod, a=1):


#    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=fram[n]
    b=fram[k]
    c=fram[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)])
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
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()))

def check(num, i, P):
  SS = S[i]
  PP = P[i]
  on = 0
  for j in range(1,1+SS[0]):
    on += num>>(SS[j]-1) & 1
    on = on%2
  if on == PP:
    return True
  else:
    return False
cnt = 0
for nu in range(2**N):
  ck = True
  for i in range(M):
    ck = ck and check(nu,i,P)
    if ck == False:
      break
  if ck == True:
    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):
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
cnt=0

for i in range(2**n):
    pattern=format(i,"b").zfill(n)
    point=0
    
    for j in range(m):
        swi=0
        for k in s[j]:
            if pattern[k-1]=="1":
              swi +=1
        if swi%2==P[j]:
          point +=1
    if point==m:
      cnt +=1
      
print(cnt)

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

for i in range(2**n):
    pattern=format(i,"b").zfill(n)
    point=0
    
    for j in range(m):
        swi=0
        for k in s[j]:
            if pattern[k-1]=="1":
              swi +=1
        if swi%2==p[j]:
          point +=1
    if point==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):
s = []
kmask = []
n,m = map(int,input().split())

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

for i in s:
    mask = 0
    for j in i[1:]:
        mask |= 1<<(j-1)        
    kmask.append(mask)

result = 0
for i in range(0<<n):
    ok = True
    for mask,odd in zip(kmask,p):
        bc = bitcount(i&mask)
        if((bc&1)!=odd):
            ok = False
            break
    if ok:
        result += 1

print(result)

def bitcount(bit):
    return bin(bit).count("1")

s = []
kmask = []
n,m = map(int,input().split())

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

for i in s:
    mask = 0
    for j in i[1:]:
        mask |= 1<<(j-1)        
    kmask.append(mask)

result = 0
for i in range(1<<n):
    ok = True
    for mask,odd in zip(kmask,p):
        bc = bitcount(i&mask)
        if((bc&1)!=odd):
            ok = False
            break
    if ok:
        result += 1

print(result)

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())
sw=[[]*m]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: ans+=1
print(ans)

n,m=map(int,input().split())
sw=[[] for _ in range(m)]
for _ in range(m):
    temp=list(map(int,input().split()))
    sw[_]=temp[1:]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    temp=[0]*n
    for j in range(n):
        if i&1: temp[j]=1
        i>>=1
    flag=1
    for l,s in enumerate(sw):
        cnt=0
        for k in s:
            if temp[k-1]==1: cnt+=1
        if p[l]!=cnt%2:
            flag=0
            break
    if flag: 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):
f=lambda:[*map(int,input().split())]
n,m=f()
S=[f()[1:] for _ in [0]*m]
p=f()
print(sum(all(sum(i>>-~k for k in S[j])%2==p[j] for j in range(m)) for i in range(2**n)))

f=lambda:[*map(int,input().split())]
n,m=f()
S=[f()[1:] for _ in [0]*m]
p=f()
print(sum(all(sum(i>>~-k for k in S[j])%2==p[j] for j in range(m)) for i in range(2**n)))

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()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
li = [[] for _ in range(N)]
for i in range(M):
    for ma in s[i]:
        li[ma - 1].append(i)
ans = 0
print(li)
for i in range(2 ** N):
    l = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            for r in li[j]:
                l[r] ^= 1
    if l == p:
        ans += 1
print(ans)

n,m=map(int,input().split())
k=[0]*m
s=[[]for _ in range(m)]
for i in range(m):
  k[i], *s[i] = map(int, input().split())
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  res=0
  for a in range(m):
    tmp=p[a]^1
    for j in s[a]:
      if (i >> (j-1)) & 1:
        tmp^=1
    res+=tmp
  if res==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())
sbit = [0] * M
for i in range(M):
  l = list(map(int, input().split()))
  bit = 0
  for j in range(1, l[0]):
    bit += 1 << l[j + 1]
  sbit[i] =  bit
p = list(map(int, input().split()))

total = 0
for tbit in range(2 ** N):
  flg = True
  for i in range(M):
    bit = sbit[i] & tbit
    bits = 0
    while bit > 0:
      if bit & 1:
        bits += 1
      bit = bit >> 1
    if bits % 2 != p[i]:
      flg = False
      break
  if flg:
    total += 1
print(total)

N,M = map(int, input().split())
sbit = [0] * M
for i in range(M):
  l = list(map(int, input().split()))
  bit = 0
  for j in range(1, l[0] + 1):
    bit += 1 << (l[j] - 1)
  sbit[i] =  bit
p = list(map(int, input().split()))

total = 0
for tbit in range(2 ** N):
  flg = True
  for i in range(M):
    bit = sbit[i] & tbit
    bits = 0
    while bit > 0:
      if bit & 1:
        bits += 1
      bit = bit >> 1
    if bits % 2 != p[i]:
      flg = False
      break
  if flg:
    total += 1
print(total)

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):
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#

#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    
    
    A = []
    for i in range(m):
        A.append(list(map(lambda x: int(x) - 1, input().split()))[1:])
    P = readInts()
    ans = 0

    for bit in range(1 << n):
        ok = True
        for i in range(m):
            con = 0
            for v in A[i]:
                print(v)
                if bit & 1 << v:
                    con += 1
            if con % 2 != P[i]:
                ok = False
        if ok:
            ans += 1
    print(ans)


if __name__ == '__main__':
  main()


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#

#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    
    
    A = []
    for i in range(m):
        A.append(list(map(lambda x: int(x) - 1, input().split()))[1:])
    P = readInts()
    ans = 0

    for bit in range(1 << n):
        ok = True
        for i in range(m):
            con = 0
            for v in A[i]:
                #print(v)
                if bit & 1 << v:
                    con += 1
            if con % 2 != P[i]:
                ok = False
        if ok:
            ans += 1
    print(ans)


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):
from scipy.special import comb
n,m = map(int,(input().split()))
bulb = [0]*m
p = [0]*m
j = 1
odd = 0
even = 0
for i in range(m):
    bulb[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

for i in range(m):
    print('bulb='+str(bulb[i][0]))
    if not bulb[i][0]%2==p[i]:
        print(0)
        exit()
    elif bulb[i][0]%2==0:
        for j in range(0,bulb[i][0]+1,2):
            even = even + comb(bulb[i][0],j, exact=True)
            
        if len(bulb[i])==2:
            even = even/2
            
    else:
        for j in range(1,bulb[i][0]+1,2):
            odd = odd + comb(bulb[i][0],j, exact=True)
          
        if len(bulb[i])==2:
            odd = odd/2              

print(int(odd*even))

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

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

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1,len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        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):
#!/usr/bin/python
# coding: UTF-8

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

s = []
for i in range(m):
    s += [tuple(map(int,input().split())),]

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

ret = 0
all = [(str(bin(i)))[2:].zfill(m) for i in range(2 ** n),]
all = [[int(i) for i in case] for case in all,]
for case in all:
    # print("------------------------------------------------")
    # print("[case = ",case,"]")
    flag = 0
    for num,i in enumerate(s):
        if flag == 1:
            continue

        # print("  [case = ",i[1:],"]")

        sw = [0 for z in range(n),]
        # print("sw",sw)
        for k in i[1:]:
            sw[k-1] = 1

        # print(sw,case)
        
        if (sum(i*j for i,j in zip(sw,case),) % 2) != p[num]:
            flag = 1
        # print("flag is ",flag)
           
    if flag == 0:
        # print(case," is ok.")
        ret += 1

print(ret)

#!/usr/bin/python
# coding: UTF-8

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

s = []
for i in range(m):
    s += [tuple(map(int,input().split())),]

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

ret = 0
all = [(str(bin(i)))[2:].zfill(n) for i in range(2 ** n)]
all = [[int(i) for i in case] for case in all]
for case in all:
    flag = 0
    for num,i in enumerate(s):
        if flag == 1:
            continue

        sw = [0 for z in range(n)]
        for k in i[1:]:
            sw[k-1] = 1

        if (sum(i*j for i,j in zip(sw,case)) % 2) != p[num]:
            flag = 1
           
    if flag == 0:
        ret += 1

print(ret)

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()))[1:]for i in range(m)]
p = list(map(int,input().split()))
form = "0"+str(n)+"b"
ans = 0
for i in range(2**n):
    ptn = format(i,form)
    light = True
    for j in range(m):
        s = sum(int(ptn[k-1])for k in s[j])
        if s%2 != p[j]:
            light = False
    if light == True:
        ans += 1
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):
    ptn = bin(i)[2:].rjust(n,"0")
    light = True
    for j in range(m):
        tmp = 0
        for k in range(1,s[j][0]+1):
            if ptn[s[j][n]-1] == "1":
                tmp += 1
        if tmp % 2 != p[j]% 2:
            light = False
    if light:
        ans += 1
print(ans)

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

form ="0"+str(n)+"b"
ans = 0
for i in range(2**n):
    ptn = format(i,form)
    light = True
    for j in range(m):
        s = sum(int(ptn[k-1])for k in l[j])
        if s%2 !=p[j]:
            light = False
    if light == True:
        ans += 1

print(ans)


Verdicts: 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):
N,M = map(int,input().split())
swis = [list(map(int,input().split()))[1:] for _ in range(M)]
need = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
  for j in range(M):
    rel=0
    for k in swis[j]:
      if i & (1<<(k-1)) != 0:
        rel+=1
        
      if rel%2 != need[j]:
        break
  else:
     ans+=1
      
print(ans)
        


N,M = map(int,input().split())
swis = [list(map(int,input().split()))[1:] for _ in range(M)]
need = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
  for j in range(M):
    rel=0
    for k in swis[j]:
      if i & 1<<(k-1) != 0:
        rel+=1
        
      if rel%2 != need[j]:
        break
  else:
     ans+=1
      
print(ans)
        

N,M = map(int,input().split())
swis = [list(map(int,input().split()))[1:] for _ in range(M)]
need = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
  for j in range(M):
    rel=0
    for k in swis[j]:
      if i & (1<<(k-1)) != 0:
        rel+=1
        
    if rel%2 != need[j]:
        break
  else:
     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())
lightList = []
for _ in range(M):
    lightList.append(list(map(int, input().split())))
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    flag = True
    for a in range(M):
        cnt = 0
        for b in lightList[a][1:]:
            if not (i & (1<<b)):
                cnt += 1
        if cnt % 2 != P[a]:
            flag = False
    if flag:
        ans += 1
print(ans)


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

ans = 0
for i in range(2**N):
    flag = True
    for a in range(M):
        cnt = 0
        for b in lightList[a][1:]:
            if (1 & (i>>(b-1))):
                cnt += 1
        if cnt % 2 != P[a]:
            flag = False
    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 _ in range(m)]
p = [int(i) for i in input().split()]

ans = 0
for i in range(1 << n):
    check = []
    for j in range(n):
        if i >> j & 1:
            check.append(j)

    check = set(check)

    flag = True
    for j in range(m):
        tmp = 0
        for k in range(1, s[j][0]):
            if s[j][k] in check:
                tmp += 1

        if tmp % 2 != p[j]:
            flag = False
            break

    if flag == True:
        ans += 1

print(ans)






N, M = map(int ,input().split())
light = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(M)]
p = [int(i) for i in input().split()]

ans = 0

for i in range(1 << N):
    flag = True
    for m in range(M):
        onsum = 0
        for j in range(N):
            if i >> j & 1 and j in light[m]:
                onsum+=1
        if onsum%2!=p[m]:
            flag = False
            break
    if flag == 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):
from numpy import*
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):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)

from numpy import*
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=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)

Verdicts: Runtime Error

Accepted