Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 6 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 8 KBi |
#9 |
Correcto
|
0.005 s | 1 KBi |
#10 |
Correcto
|
0.006 s | 1 KBi |
#11 |
Correcto
|
0.005 s | 1 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.005 s | 1 KBi |
#14 |
Correcto
|
0.005 s | 1 KBi |
#15 |
Correcto
|
0.006 s | 1 KBi |
#16 |
Correcto
|
0.008 s | 1 KBi |
#17 |
Correcto
|
0.006 s | 1 KBi |
#18 |
Correcto
|
0.006 s | 1 KBi |
#19 |
Correcto
|
0.007 s | 1 KBi |
#20 |
Correcto
|
0.007 s | 1 KBi |
/* https://codeo.app/problemas/0xe1-cuadrado-magico 0xe1 - Cuadrado mágico Tenemos una matriz cuadrada de N x N números enteros. Decimos que la matriz es un cuadrado mágico si la suma de sus filas, columnas y diagonales es es siempre la misma. */ #include <iostream> #include <vector> using namespace std; int main() { int n, targetSum; cin >> n; int numbers[n][n]; bool allEqual; vector<int> rows(n, 0); vector<int> cols(n, 0); vector<int> diag(2, 0); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> numbers[i][j]; // sums for (int i = 0; i < n; i++) { diag[0] += numbers[i][i]; diag[1] += numbers[n - i - 1][i]; for (int j = 0; j < n; j++) { rows[i] += numbers[i][j]; cols[i] += numbers[j][i]; } } allEqual = true; targetSum = rows[0]; if (diag[0] != targetSum || diag[1] != targetSum) allEqual = false; for (int i = 0; i < n; i++) { if (rows[i] != targetSum || cols[i] != targetSum) { allEqual = false; break; } } cout << (allEqual ? "Yes" : "No") << endl; return 0; }