2825 - Chenar 2

From Bitnami MediaWiki
Revision as of 18:53, 3 April 2023 by MiclausIoana (talk | contribs) (Pagină nouă: == Rezolvare == <syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] x = int(input()) for i in range(n): for j in range(m): if i == 0 or i == n-1 or j == 0 or j == m-1: if a[i][j] == x: print("DA") exit() print("NU") </syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Rezolvare

<syntaxhighlight lang="python" line="1"> n, m = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] x = int(input())

for i in range(n):

   for j in range(m):
       if i == 0 or i == n-1 or j == 0 or j == m-1:
           if a[i][j] == x:
               print("DA")
               exit()

print("NU") </syntaxhighlight>