0777 - Cnt Coloane

From Bitnami MediaWiki
Revision as of 18:45, 3 April 2023 by MiclausIoana (talk | contribs) (Pagină nouă: == Rezolvare == <syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) matrix = [] for i in range(n): row = list(map(int, input().split())) matrix.append(row) count = 0 for j in range(m): column = [matrix[i][j] for i in range(n)] if len(set(column)) == n: count += 1 print(count) </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rezolvare

<syntaxhighlight lang="python" line="1"> n, m = map(int, input().split())

matrix = [] for i in range(n):

   row = list(map(int, input().split()))
   matrix.append(row)

count = 0 for j in range(m):

   column = [matrix[i][j] for i in range(n)]
   if len(set(column)) == n:
       count += 1

print(count) </syntaxhighlight>