Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.02 s | 3 KBi |
#2 |
Correcto
|
0.034 s | 3 KBi |
#3 |
Correcto
|
0.026 s | 3 KBi |
#4 |
Correcto
|
0.03 s | 3 KBi |
#5 |
Correcto
|
0.024 s | 3 KBi |
#6 |
Correcto
|
0.034 s | 3 KBi |
#7 |
Correcto
|
0.031 s | 3 KBi |
#8 |
Correcto
|
0.021 s | 3 KBi |
#9 |
Correcto
|
0.027 s | 3 KBi |
#10 |
Correcto
|
0.033 s | 3 KBi |
#11 |
Correcto
|
0.023 s | 3 KBi |
#12 |
Correcto
|
0.03 s | 3 KBi |
#13 |
Correcto
|
0.022 s | 3 KBi |
#14 |
Correcto
|
0.02 s | 3 KBi |
#15 |
Correcto
|
0.033 s | 3 KBi |
#16 |
Correcto
|
0.041 s | 3 KBi |
#17 |
Correcto
|
0.032 s | 4 KBi |
#18 |
Correcto
|
0.025 s | 3 KBi |
#19 |
Correcto
|
0.032 s | 3 KBi |
#20 |
Correcto
|
0.025 s | 3 KBi |
def is_magic_square(n, square): c = sum(square[0]) # Rows for i in range(1, n): if sum(square[i]) != c: return False # Cols for j in range(0, n): s = 0 for i in range(n): s += square[i][j] if s != c: return False # Diagonal 1 s = sum(square[i][i] for i in range(n)) if s != c: return False # Diagonal 2 s = sum(square[i][n - i - 1] for i in range(n)) if s != c: return False return True n = int(input()) square = [] for _ in range(n): row = [int(j) for j in input().split()] square.append(row) ans = is_magic_square(n, square) print('Yes' if ans else 'No')