Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.03 s | 3 KBi |
#2 |
Correcto
|
0.026 s | 3 KBi |
#3 |
Correcto
|
0.017 s | 3 KBi |
#4 |
Correcto
|
0.032 s | 3 KBi |
#5 |
Correcto
|
0.028 s | 3 KBi |
#6 |
Correcto
|
0.031 s | 3 KBi |
#7 |
Correcto
|
0.031 s | 3 KBi |
#8 |
Correcto
|
0.022 s | 3 KBi |
#9 |
Correcto
|
0.024 s | 3 KBi |
#10 |
Correcto
|
0.019 s | 3 KBi |
#11 |
Correcto
|
0.017 s | 3 KBi |
#12 |
Correcto
|
0.023 s | 3 KBi |
#13 |
Correcto
|
0.031 s | 3 KBi |
#14 |
Correcto
|
0.023 s | 3 KBi |
#15 |
Correcto
|
0.026 s | 3 KBi |
#16 |
Correcto
|
0.031 s | 3 KBi |
#17 |
Correcto
|
0.021 s | 3 KBi |
#18 |
Correcto
|
0.025 s | 3 KBi |
#19 |
Correcto
|
0.023 s | 3 KBi |
#20 |
Correcto
|
0.028 s | 3 KBi |
listOfLists = [] size = int(input()) count = size while (count > 0): elements = list(map(int, input().rsplit(" "))) assert size == len(elements), "Different length." listOfLists.append(elements) count -= 1 sumSubLists = list(map(sum, listOfLists)) if all(i == sumSubLists[0] for i in sumSubLists): columnList = [] for subList in listOfLists: sumColumns = [] sumC = 0 for item in subList: sumC += item sumColumns.append(sumC) columnList.append(sumColumns) sumColumns = list(map(sum, columnList)) if all(i == sumSubLists[0] for i in sumColumns): diagonalList = list(listOfLists[i][i] for i in range(len(listOfLists))) sumDiagonals = [] sumD = 0 for d in diagonalList: sumD += d sumDiagonals.append(sumD) lastD = sumDiagonals.pop() if (lastD == sumSubLists[0]): antiDiagonalList = list(listOfLists[i][len(listOfLists)-i-1] for i in range(len(listOfLists))) sumAntiDiagonals = [] sumAd = 0 for ad in antiDiagonalList: sumAd += ad sumAntiDiagonals.append(sumAd) lastAd = sumAntiDiagonals.pop() if (lastAd == sumColumns[0]): print("Yes") else: print("No") else: print("No") else: print("No") else: print("No")