-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontest.py
More file actions
45 lines (40 loc) · 1.03 KB
/
contest.py
File metadata and controls
45 lines (40 loc) · 1.03 KB
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
while True:
lines, columns = map(int, input().split(' '))
if lines == 0 and columns == 0:
break
result = 0
case1 = True
case2 = False
case3 = True
case4 = True
matrix = []
solved = [0] * columns
for x in range(lines):
newLine = list(map(int, input().split()))
matrix.append(newLine)
for line in matrix:
if line.count(1) == columns:
case1 = False
if line.count(1) == 0:
case4 = False
for idx in range(columns):
if solved[idx] == 0 and line[idx] == 1:
solved[idx] = 1
checklist = []
for column in range(columns):
for line in range(lines):
checklist.append(matrix[line][column])
if checklist.count(1) == lines:
case3 = False
checklist = []
if solved.count(1) == columns:
case2 = True
if case1:
result += 1
if case2:
result += 1
if case3:
result += 1
if case4:
result += 1
print(result)