Source Code
tmp = input()
tmp = tmp.split(" ")
n, m = int(tmp[0]), int(tmp[1])

conds = [False] * n
a = ["A"*m] * n
for i in range(0, n):
    a[i] = input()

for c in range(0, m):
    o = 0
    for r in range(0, n):
        if (a[r][c] == '1'):
            o += 1
            index = r
    if (o == 1):
        conds[index] = True
      
ans = 0  
for i in conds:
    if (i):
        ans += 1
print(ans)
Copy
Obada Discovers His Hearing Issues SilverCryptor
Python 3
128 ms
4.4 MB
Accepted