You are given an integer N denoting an N×N matrix. Initially, each cell of the matrix is empty. You are given K tasks. In each task, you are given a cell (i,j) where cell (i,j) represents the
ith row and jth column of the given matrix.
def cells(N, K, tks):
r = set([i+1 for i in range(N)])
c = set([i+1 for i in range(N)])
res = []
for tk in tks:
r.discard(tk[0])
c.discard(tk[1])
res.append(len(r)*len(c))
return res
N, K = map(int, input().split())
tk = []
for n in range(K):
i, j = map(int, input().split())
X = i, j
tk.append(X)
t = cells(N, K, tk)
print (' '.join(map(str, t)))
Comments
Leave a comment