Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 64 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.005 s | 2 KBi |
#10 |
Correcto
|
0.005 s | 1 KBi |
#11 |
Correcto
|
0.006 s | 1 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.006 s | 21 KBi |
#14 |
Correcto
|
0.005 s | 1 KBi |
#15 |
Correcto
|
0.005 s | 1 KBi |
#16 |
Correcto
|
0.008 s | 1 KBi |
#17 |
Correcto
|
0.006 s | 3 KBi |
#18 |
Correcto
|
0.007 s | 1 KBi |
#19 |
Correcto
|
0.007 s | 9 KBi |
#20 |
Correcto
|
0.007 s | 1 KBi |
#include <iostream> #include <vector> using namespace std; bool solve(int N, vector<vector<int>> matrix, int diag1, int diag2) { if (diag1 != diag2) { return false; } if (matrix[0][N - 1] != diag1 or matrix[N - 1][0] != diag1) { return false; } for (int i = 1; i < N; ++i) { if (matrix[N - 1][i] - matrix[N - 1][i - 1] != diag1) { return false; } if (matrix[i][N - 1] - matrix[i - 1][N - 1] != diag1) { return false; } } return true; } int main() { int N; cin >> N; vector<vector<int>> matrix(N, vector<int>(N)); int diag1 = 0; int diag2 = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { cin >> matrix[i][j]; if (i == j) { diag1 += matrix[i][j]; } if (i + j + 1 == N) { diag2 += matrix[i][j]; } if (j > 0) { matrix[i][j] += matrix[i][j - 1]; } } } for (int i = 1; i < N; ++i) { for (int j = 0; j < N; ++j) { matrix[i][j] += matrix[i - 1][j]; } } cout << (solve(N, matrix, diag1, diag2) ? "Yes" : "No") << endl; }