█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 7071

Problema 0xe1 - Cuadrado mágico

Caso # Resultado Tiempo Memoria
#1
Correcto
0.021 s 3 KBi
#2
Correcto
0.015 s 3 KBi
#3
Correcto
0.022 s 3 KBi
#4
Correcto
0.015 s 3 KBi
#5
Correcto
0.022 s 3 KBi
#6
Correcto
0.017 s 3 KBi
#7
Correcto
0.023 s 3 KBi
#8
Correcto
0.015 s 3 KBi
#9
Correcto
0.018 s 3 KBi
#10
Correcto
0.018 s 3 KBi
#11
Correcto
0.018 s 3 KBi
#12
Correcto
0.018 s 3 KBi
#13
Correcto
0.015 s 3 KBi
#14
Correcto
0.015 s 3 KBi
#15
Correcto
0.024 s 3 KBi
#16
Correcto
0.024 s 3 KBi
#17
Correcto
0.026 s 3 KBi
#18
Correcto
0.024 s 3 KBi
#19
Correcto
0.031 s 3 KBi
#20
Correcto
0.024 s 3 KBi
Puntos totales: 100 / 100

Código

n = int(input())
squareData = []
for i in range(0, n):
    squareData.append([int(item) for item in input().split()])

result = [0] * ((2 * n) + 2)
for i in range(0, n):
    sumJ = 0
    for j in range(0, n):
        sumJ = sumJ + squareData[i][j]
        result[j] = result[j] + squareData[i][j]
        if i == j: 
            result[(2 * n)] = result[(2 * n)] + squareData[i][j]
        if i == n - j - 1: 
            result[(2 * n) + 1] = result[(2 * n) + 1] + squareData[i][j]
    result[n + i] = sumJ

response = "Yes"
for i in range(0, len(result) - 1):
    if result[i] != result[i + 1]:
        response = "No"
        break

print(response)