Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 3 KBi |
#2 |
Correcto
|
0.004 s | 2 KBi |
#3 |
Correcto
|
0.004 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 2 KBi |
#5 |
Correcto
|
0.004 s | 8 KBi |
#6 |
Correcto
|
0.003 s | 6 KBi |
#7 |
Correcto
|
0.004 s | 1 KBi |
#8 |
Correcto
|
0.004 s | 5 KBi |
#9 |
Correcto
|
0.004 s | 5 KBi |
#10 |
Correcto
|
0.003 s | 0 KBi |
#11 |
Correcto
|
0.004 s | 1 KBi |
#12 |
Correcto
|
0.003 s | 1 KBi |
#13 |
Correcto
|
0.005 s | 5 KBi |
#14 |
Correcto
|
0.004 s | 1 KBi |
#15 |
Correcto
|
0.004 s | 1 KBi |
#16 |
Correcto
|
0.008 s | 1 KBi |
#17 |
Correcto
|
0.005 s | 1 KBi |
#18 |
Correcto
|
0.006 s | 1 KBi |
#19 |
Correcto
|
0.006 s | 1 KBi |
#20 |
Correcto
|
0.007 s | 2 KBi |
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; int l = n * n; bool isMagic = true; // d1, d2, hv int v[4] = {0, 0, 0, 0}; int m[l]; for (int i = 0; i < l; i++) { cin >> m[i]; } for (int i = 0; i < l; i += n + 1) v[0] += m[i]; for (int i = n - 1; i < l - 1; i += n - 1) { v[1] += m[i]; } if (v[0] == v[1]) { if (isMagic) { for (int i = 0; i < n; i++) { v[2] = 0, v[3] = 0; // rows for (int j = n * i; j < n * i + n; j++) v[2] += m[j]; // cols for (int j = i; j < l; j += n) v[3] += m[j]; if (v[0] != v[2] || v[0] != v[3]) { isMagic = false; break; } } } } else { isMagic = false; } cout << (isMagic ? "Yes" : "No") << endl; return 0; }