Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.005 s | 10 KBi |
#2 |
Incorrecto
|
0.005 s | 1 KBi |
#3 |
Incorrecto
|
0.006 s | 2 KBi |
#4 |
Incorrecto
|
0.005 s | 1 KBi |
#5 |
Incorrecto
|
0.005 s | 1 KBi |
#6 |
Incorrecto
|
0.005 s | 2 KBi |
#7 |
Incorrecto
|
0.005 s | 1 KBi |
#8 |
Incorrecto
|
0.005 s | 1 KBi |
#9 |
Incorrecto
|
0.005 s | 3 KBi |
#10 |
Incorrecto
|
0.005 s | 1 KBi |
#11 |
Incorrecto
|
0.005 s | 1 KBi |
#12 |
Incorrecto
|
0.005 s | 1 KBi |
#13 |
Incorrecto
|
0.005 s | 1 KBi |
#14 |
Incorrecto
|
0.005 s | 1 KBi |
#15 |
Incorrecto
|
0.005 s | 1 KBi |
#16 |
Incorrecto
|
0.008 s | 2 KBi |
#17 |
Incorrecto
|
0.007 s | 1 KBi |
#18 |
Incorrecto
|
0.006 s | 1 KBi |
#19 |
Incorrecto
|
0.007 s | 1 KBi |
#20 |
Incorrecto
|
0.007 s | 1 KBi |
#include <iostream> #include <vector> using namespace std; int main() { int n, sum, magic=-1; cin >> n; int square[n][n]; int cols[n], rows[n], diag1=0, diag2=0; for(int row=0;row<n;row++){ rows[row]= 0; for(int col=0;col<n;col++){ cin >> square[row][col]; int current = square[row][col]; if(row == 0){ cols[col] = current; } else{ cols[col] += current; } rows[row] += current; if(row==col){ diag1+=current; } if(col== (n-1-row) ){ diag2+=current; } } } magic = rows[0]; if(magic != diag1){ // cout << "diag1 " << diag1 << endl; cout << "NO"; return 0; } if(magic != diag2){ //cout << "diag " << diag2 << endl; cout << "NO"; return 0; } for(int row=1;row<n;row++){ if(rows[row]!=magic){ // cout << "row " << row << endl; cout << "NO"; return 0; } } for(int col=1;col<n;col++){ if(cols[col]!=magic){ // cout << "col " << col << endl; cout << "NO"; return 0; } } cout << "YES"; }