Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 0 KBi |
#2 |
Correcto
|
0.005 s | 4 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 0 KBi |
#5 |
Correcto
|
0.004 s | 0 KBi |
#6 |
Correcto
|
0.004 s | 0 KBi |
#7 |
Correcto
|
0.004 s | 1 KBi |
#8 |
Correcto
|
0.004 s | 0 KBi |
#9 |
Incorrecto
|
0.005 s | 0 KBi |
#10 |
Incorrecto
|
0.006 s | 1 KBi |
#11 |
Correcto
|
0.004 s | 5 KBi |
#12 |
Correcto
|
0.004 s | 1 KBi |
#13 |
Correcto
|
0.004 s | 5 KBi |
#14 |
Correcto
|
0.003 s | 19 KBi |
#15 |
Correcto
|
0.004 s | 0 KBi |
#16 |
Correcto
|
0.008 s | 0 KBi |
#17 |
Correcto
|
0.007 s | 4 KBi |
#18 |
Correcto
|
0.008 s | 0 KBi |
#19 |
Correcto
|
0.007 s | 0 KBi |
#20 |
Correcto
|
0.011 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 for (int i = 0; i < N; i++) { int 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]; } if (!isMagic || diagonal1 != diagonal2) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }