Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def countMatchedSwitch(sw_status, switch, index):
  4. ret = 0
  5. for s in switch[index]:
  6. if int(sw_status[int(s) - 1]) == 1:
  7. ret += 1
  8. return ret % 2
  9.  
  10.  
  11. if __name__ == '__main__':
  12. N, M = [int(i) for i in input().split()]
  13. s = []
  14. for i in range(M):
  15. data = input().split()
  16. s.append(data[1:])
  17. p = [int(i) for i in input().split()]
  18.  
  19. ret = 0
  20. for i in range(2**N):
  21. is_all_passed = True
  22. sw_status = bin(i)[2:].zfill(N)
  23. for j in range(M):
  24. if p[j] != countMatchedSwitch(sw_status, s, j):
  25. is_all_passed = False
  26. if is_all_passed:
  27. ret += 1
  28. print("{ret}".format(ret=ret))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement