-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSafe.py
53 lines (39 loc) · 808 Bytes
/
DSafe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def process( s,i,n,rule ):
global ans
if i==n:
print(s)
for r,c in rule:
sc = 0
for i in range(n):
if s[i]==r[i]:
sc += 1
if sc >= c:
print("YES")
break
if sc < c:
print("NO")
ans -= 1
break
return
s[i] = 1
process(s,i+1,n,rule)
s[i] = 0
process(s,i+1,n,rule)
n,m = [int(i) for i in input().split()]
rule = []
for i in range(m):
s,j = input().split()
j = int(j)
rule.append( ([int(k) for k in s],j) )
s = [0]*n
ans = 1<<n
print(ans)
print(rule)
process(s,0,n,rule)
print(ans)
'''
6 3
000000 2
010100 4
111100 2
'''