using namespace std;
pair findSaddlePoint(const vector>& matrix) {
int rows = matrix.size();
int cols = matrix[0].size();
for (int i = 0; i < rows; i++) {
int minRow = matrix[i][0]; // Satrning eng kichik elementini topish uchun boshlang'ich qiymat
int colIndex = 0; // Eng kichik elementning indeksi
// Satrning eng kichik elementini topish
for (int j = 1; j < cols; j++) {
if (matrix[i][j] < minRow) {
minRow = matrix[i][j];
colIndex = j;
}
}
bool isSaddlePoint = true;
// Eng kattasi ustunni tekshirish
for (int k = 0; k < rows; k++) {
if (matrix[k][colIndex] > minRow) {
isSaddlePoint = false;
break;
}
}
// Egar nuqta topildi
if (isSaddlePoint) {
return make_pair(i, colIndex);
}
}
// Egar nuqta topilmadi
return make_pair(-1, -1);
}
int main() {
int rows, cols;
cout << "Matritsa o'lchamlarini kiriting:\n";
cout << "Satr: ";
cin >> rows;
cout << "Ustun: ";
cin >> cols;
vector> matrix(rows, vector(cols));
cout << "Matritsa elementlarini kiriting:\n";
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cin >> matrix[i][j];
}
}
pair saddlePoint = findSaddlePoint(matrix);
if (saddlePoint.first == -1 && saddlePoint.second == -1) {
cout << "Egar nuqta topilmadi.\n";
} else {
cout << "Egar nuqta indeksi: (" << saddlePoint.first << ", " << saddlePoint.second << ")\n";
}
return 0;
}