Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.003 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.004 s | 1 KBi |
#8 |
Correcto
|
0.004 s | 1 KBi |
#9 |
Correcto
|
0.005 s | 1 KBi |
#10 |
Correcto
|
0.005 s | 1 KBi |
#11 |
Correcto
|
0.003 s | 1 KBi |
#12 |
Correcto
|
0.004 s | 1 KBi |
#13 |
Correcto
|
0.004 s | 1 KBi |
#14 |
Correcto
|
0.005 s | 1 KBi |
#15 |
Correcto
|
0.005 s | 1 KBi |
#16 |
Correcto
|
0.007 s | 1 KBi |
#17 |
Correcto
|
0.007 s | 1 KBi |
#18 |
Correcto
|
0.007 s | 1 KBi |
#19 |
Correcto
|
0.006 s | 1 KBi |
#20 |
Correcto
|
0.008 s | 1 KBi |
#include <iostream> using namespace std; bool isMagic() { int n; cin >> n; int square[n][n]; int d1 = 0; int d2 = 0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { cin >> square[i][j]; } } int want = 0; for(int i=0;i<n;i++) want += square[0][i]; for(int i=0;i<n;i++) { int sumC = 0; int sumF = 0; for(int j=0;j<n;j++) { sumC += square[j][i]; sumF += square[i][j]; if(i == j)d1 += square[i][j]; if(i == (n-1-j))d2 += square[i][j]; } if(sumC != sumF || sumF != want ) return false; } if(d1 != d2) { return false; } return true; } int main() { bool resp = isMagic(); if(resp) cout << "Yes" << endl; else cout << "No" << endl; }