Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.003 s | 0 KBi |
#2 |
Correcto
|
0.003 s | 0 KBi |
#3 |
Correcto
|
0.006 s | 0 KBi |
#4 |
Correcto
|
0.004 s | 0 KBi |
#5 |
Correcto
|
0.005 s | 0 KBi |
#6 |
Correcto
|
0.003 s | 0 KBi |
#7 |
Correcto
|
0.004 s | 3 KBi |
#8 |
Correcto
|
0.008 s | 0 KBi |
#9 |
Correcto
|
0.006 s | 1 KBi |
#10 |
Incorrecto
|
0.004 s | 0 KBi |
#11 |
Correcto
|
0.005 s | 12 KBi |
#12 |
Correcto
|
0.006 s | 0 KBi |
#13 |
Correcto
|
0.005 s | 1 KBi |
#14 |
Correcto
|
0.005 s | 0 KBi |
#15 |
Correcto
|
0.006 s | 0 KBi |
#16 |
Correcto
|
0.01 s | 0 KBi |
#17 |
Correcto
|
0.005 s | 2 KBi |
#18 |
Correcto
|
0.006 s | 0 KBi |
#19 |
Correcto
|
0.009 s | 0 KBi |
#20 |
Correcto
|
0.009 s | 0 KBi |
#include <iostream> #include <vector> using namespace std; int main () { int N, n; bool isMagic = true; cin >> N; n = N; vector<vector<int> > matriz(N, vector<int>(N)); while (n--) { for (int i = 0; i < N; i++) { cin >> matriz[n][i]; } } //vertical-horizontal check int verticalSum, horizontalSum; for (int i = 0; i < N; i++) { verticalSum = 0; horizontalSum = 0; for (int j = 0; j < N; j++) { horizontalSum += matriz[i][j]; verticalSum += matriz[j][i]; } if (horizontalSum != verticalSum) { isMagic = false; break; } } // diagonal check int diagonal1 = 0, diagonal2 = 0; for (int i = 0, j = N-1; i < N; i++, j--) { diagonal1 += matriz[i][i]; diagonal2 += matriz[i][j]; } bool diagonals = diagonal1 == verticalSum && diagonal1 == diagonal2 && isMagic; if (!isMagic || !diagonals) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }