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