Softeer 나무공격

Softeer 나무공격

import sys
m, n = map(int, sys.stdin.readline().split())
matrix = []
for i in range(m):
    matrix.append(list(map(int, sys.stdin.readline().split())))
a, b = map(int, sys.stdin.readline().split())
c, d = map(int, sys.stdin.readline().split())

count = 0
for row in range(a-1, b):
    for i in range(n):
        if matrix[row][i]==1:
            matrix[row][i] = 0
            break
for row in range(c-1, d):
    for i in range(n):
        if matrix[row][i]==1:
            matrix[row][i] = 0
            break
for row in range(m):
    for i in matrix[row]:
        if i==1:
            count += 1

print(count)