Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.007 s | 2 KBi |
#4 |
Correcto
|
0.007 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.007 s | 2 KBi |
#7 |
Correcto
|
0.006 s | 10 KBi |
#8 |
Correcto
|
0.006 s | 7 KBi |
#9 |
Correcto
|
0.007 s | 2 KBi |
#10 |
Correcto
|
0.007 s | 1 KBi |
#11 |
Correcto
|
0.006 s | 1 KBi |
#12 |
Correcto
|
0.006 s | 11 KBi |
#13 |
Correcto
|
0.009 s | 1 KBi |
#14 |
Correcto
|
0.005 s | 2 KBi |
#15 |
Correcto
|
0.007 s | 10 KBi |
#16 |
Correcto
|
0.008 s | 2 KBi |
#17 |
Correcto
|
0.009 s | 2 KBi |
#18 |
Correcto
|
0.011 s | 1 KBi |
#19 |
Correcto
|
0.012 s | 2 KBi |
#20 |
Correcto
|
0.01 s | 2 KBi |
#include <iostream> using namespace std; const int MAXN = 100; int matrix[MAXN][MAXN]; bool is_magic_square(int n){ int want = 0; for(int c=0;c<n;c++){ want += matrix[0][c]; } for(int r=0;r<n;r++){ int sum =0; for(int c= 0 ; c<n; c++){ sum += matrix[r][c]; } if(sum != want){ return false; } } for(int c=0; c<n; c++){ int sum =0 ; for(int r= 0 ; r<n; r++){ sum += matrix[r][c]; } if(sum != want){ return false; } } int sum = 0; for(int i=0;i<n;i++){ sum += matrix[i][i]; } if(sum != want){ return false; } sum =0; for(int i = 0;i<n;i++){ sum += matrix[i][n-1-i]; } if(sum != want){ return false; } return true; } int main(){ int n; cin >> n; for(int r = 0;r<n;r++){ for(int c =0;c<n;c++){ cin >> matrix[r][c]; } } if(is_magic_square(n)){ cout << "Yes"; }else{ cout << "No"; } return 0; }