#include #pragma gcc optimize("Ofast, inline") int main(void) { int n, m; scanf("%d%d", &n, &m); int matrix[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &matrix[i][j]); } } // Find the saddle point int maxrow, max; int found = 0, x = 0, y = 0; for (int i = 0; i < n && !found; i++) { max = matrix[i][0]; maxrow = 0; // Find the largest in row i for (int j = 0; j < m; j++) { if (matrix[i][j] > max) { max = matrix[i][j]; maxrow = j; } } // test if is also the min in the column found = 1; x = i; y = maxrow; for (int j = 0; j < n; j++) { if (matrix[j][maxrow] < max) { found = 0; break; } } } if (found) { printf("The saddle point is (%d,%d)=%d.\n", x, y, matrix[x][y]); } else { printf("There is no saddle point in the matrix.\n"); } return 0; }