Answer to Question #258968 in Python for jeeva

Question #258968

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.


1
Expert's answer
2021-10-30T13:31:57-0400
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)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog