Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.019 s | 3 KBi |
#2 |
Correcto
|
0.026 s | 3 KBi |
#3 |
Correcto
|
0.019 s | 3 KBi |
#4 |
Correcto
|
0.02 s | 3 KBi |
#5 |
Correcto
|
0.02 s | 3 KBi |
#6 |
Correcto
|
0.02 s | 3 KBi |
#7 |
Correcto
|
0.024 s | 3 KBi |
#8 |
Correcto
|
0.021 s | 3 KBi |
#9 |
Correcto
|
0.022 s | 3 KBi |
#10 |
Correcto
|
0.023 s | 3 KBi |
#11 |
Correcto
|
0.026 s | 3 KBi |
#12 |
Correcto
|
0.02 s | 3 KBi |
#13 |
Correcto
|
0.019 s | 3 KBi |
#14 |
Correcto
|
0.022 s | 3 KBi |
#15 |
Correcto
|
0.025 s | 3 KBi |
#16 |
Correcto
|
0.025 s | 3 KBi |
#17 |
Correcto
|
0.022 s | 3 KBi |
#18 |
Correcto
|
0.03 s | 3 KBi |
#19 |
Correcto
|
0.029 s | 3 KBi |
#20 |
Correcto
|
0.032 s | 3 KBi |
n = int(input()) square = [] sums = { "diagonalA": 0, "diagonalB": 0, "vertical": 0, "horizontal": 0 } is_magic = True for i in range(0, n): square.append(list(map(int, input().split(" ")))) sums["diagonalA"] += square[i][i] sums["diagonalB"] += square[i][n - (i + 1)] if sums["diagonalA"] != sums["diagonalB"]: is_magic = False else: for i in square: if sum(i) != sums["diagonalA"]: is_magic = False break if is_magic is False: for col in range(0, n): v_sum = 0 for row in square: v_sum += row[col] if v_sum != sums["diagonalA"]: is_magic = False break print("Yes" if is_magic else "No")