#include "locmin.h"
#include <utility>
int n, m;
int a[501][501];
bool check(int lin, int col){
    int cur = a[lin][col];
    if((lin > 1 && a[lin - 1][col] < cur) ||
        (lin < n && a[lin + 1][col] < cur) ||
        (col > 1 && a[lin][col - 1] < cur) ||
        (col < m && a[lin][col + 1] < cur)
       )
    {
        return false;
    }
    return true;
}
std::pair <int, int> find_locmin_point(int N, int M) {
    for(int i = 1;i<=N;i++){
        for(int j = 1;j<=M;j++){
            a[i][j] = value(i, j);
        }
    }
    int rezl = 0, rezc = 0;
    n = N;
    m = M;
    for(int i = 1;i<=N;i++){
        for(int j = 1;j<=M;j++){
            if(check(i, j)){
                rezl = i, rezc = j;
                break;
            }
        }
    }
    return {rezl, rezc};
}

