Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 20 KBi |
#2 |
Correcto
|
0.003 s | 0 KBi |
#3 |
Correcto
|
0.003 s | 0 KBi |
#4 |
Correcto
|
0.008 s | 2 KBi |
#5 |
Correcto
|
0.004 s | 7 KBi |
#6 |
Correcto
|
0.005 s | 6 KBi |
#7 |
Correcto
|
0.006 s | 26 KBi |
#8 |
Correcto
|
0.005 s | 6 KBi |
#9 |
Correcto
|
0.003 s | 0 KBi |
#10 |
Correcto
|
0.009 s | 37 KBi |
#11 |
Correcto
|
0.004 s | 52 KBi |
#12 |
Correcto
|
0.005 s | 2 KBi |
#13 |
Correcto
|
0.007 s | 1 KBi |
#14 |
Correcto
|
0.004 s | 5 KBi |
#15 |
Correcto
|
0.005 s | 2 KBi |
#16 |
Correcto
|
0.01 s | 10 KBi |
#17 |
Correcto
|
0.006 s | 2 KBi |
#18 |
Correcto
|
0.011 s | 1 KBi |
#19 |
Correcto
|
0.007 s | 2 KBi |
#20 |
Correcto
|
0.012 s | 26 KBi |
#include <iostream> #include <bits/stdc++.h> using namespace std; bool verificar(int a[100][100], int base); int n; int main() { bool r = true; cin >> n; int a[100][100]; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ cin >> a[i][j]; } } int base = 0; for(int i=0; i<n ; i++) base += a[0][i]; r = verificar(a, base); r? cout << "Yes" : cout << "No"; } bool verificar(int a[100][100], int base){ bool r = true; //suma filas for(int i=0; i<n; i++){ int suma = 0; for(int j=0; j<n; j++){ suma+=a[i][j]; } if(suma != base) return false; } // suma columnas for(int i=0; i<n; i++){ int suma = 0; for(int j=0; j<n; j++){ suma+=a[j][i]; } if(suma != base) return false; } // suma diagonal int suma = 0; for(int i=0;i<n;i++){ suma+=a[i][i]; } if(suma != base) return false; // suma diagonal inversa suma = 0; for(int i=0;i<n;i++){ suma+=a[i][n-1-i]; } if(suma != base) return false; return r; }