Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 2 KBi |
#2 |
Correcto
|
0.001 s | 0 KBi |
#3 |
Correcto
|
0.004 s | 27 KBi |
#4 |
Correcto
|
0.002 s | 2 KBi |
#5 |
Correcto
|
0.001 s | 0 KBi |
#6 |
Correcto
|
0.004 s | 8 KBi |
#7 |
Correcto
|
0.003 s | 22 KBi |
#8 |
Correcto
|
0.004 s | 0 KBi |
#9 |
Correcto
|
0.004 s | 3 KBi |
#10 |
Correcto
|
0.004 s | 4 KBi |
#11 |
Correcto
|
0.002 s | 0 KBi |
#12 |
Correcto
|
0.002 s | 2 KBi |
#13 |
Correcto
|
0.004 s | 53 KBi |
#14 |
Correcto
|
0.005 s | 3 KBi |
#15 |
Correcto
|
0.001 s | 0 KBi |
#16 |
Correcto
|
0.002 s | 0 KBi |
#17 |
Correcto
|
0.009 s | 0 KBi |
#18 |
Correcto
|
0.002 s | 0 KBi |
#19 |
Correcto
|
0.01 s | 65 KBi |
#20 |
Correcto
|
0.01 s | 13 KBi |
#include<bits/stdc++.h> using namespace std; void tests(){ int n, sum = 0, sum_c = 0; cin>>n; bool magic_square = true; vector<vector<int>> matrix; for (int i = 0; i < n; i++){ matrix.emplace_back(vector<int> ()); for (int j = 0; j < n; j++){ int k; cin>>k; matrix[i].push_back(k); } } for(int i = 0; i < n; i ++){ sum += matrix[i][i]; sum_c += matrix[i][(n - i) - 1]; } if (sum_c != sum) { magic_square = false; } for (int i = 0; i < n && magic_square; i++){ int sum_v = 0, sum_h = 0; for (int j = 0; j < n; j++){ sum_v += matrix[i][j]; sum_h += matrix[j][i]; } if (sum_h != sum || sum_v != sum){ magic_square = false; break; } } cout<<(magic_square ? "Yes": "No")<<'\n'; } int main(){ tests(); }