Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
Compilation time limit exceeded. |
||
#2 |
Error de compilación
Compilation time limit exceeded. |
||
#3 |
Error de compilación
Compilation time limit exceeded. |
||
#4 |
Error de compilación
Compilation time limit exceeded. |
||
#5 |
Error de compilación
Compilation time limit exceeded. |
||
#6 |
Error de compilación
Compilation time limit exceeded. |
||
#7 |
Error de compilación
Compilation time limit exceeded. |
||
#8 |
Error de compilación
Compilation time limit exceeded. |
||
#9 |
Correcto
|
0.006 s | 6 KBi |
#10 |
Error de compilación
Compilation time limit exceeded. |
||
#11 |
Error de compilación
Compilation time limit exceeded. |
||
#12 |
Error de compilación
Compilation time limit exceeded. |
||
#13 |
Error de compilación
Compilation time limit exceeded. |
||
#14 |
Error de compilación
Compilation time limit exceeded. |
||
#15 |
Error de compilación
Compilation time limit exceeded. |
||
#16 |
Error de compilación
Compilation time limit exceeded. |
||
#17 |
Error de compilación
Compilation time limit exceeded. |
||
#18 |
Error de compilación
Compilation time limit exceeded. |
||
#19 |
Error de compilación
Compilation time limit exceeded. |
||
#20 |
Error de compilación
Compilation time limit exceeded. |
#include <bits/stdc++.h> 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; }