#include "locmin.h"
#include <bits/stdc++.h>
const int MAXN = 500;

long long mat[MAXN * 2][MAXN * 2];
int dl[] = { 0, -1, 1, 0 };
int dc[] = { 1, 0, 0, -1 };

bool verif( int i, int j ) {
    if( mat[i][j] < mat[i][j + 1] && mat[i][j] < mat[i][j - 1] )
        return 1;
    return 0;
    //int cnt = 0;
    //for( int dir = 0; dir < 4; dir++ )
    //    if( mat[i + dl[dir]][j + dc[dir]] >= mat[i][j] )
    //        cnt++;
    //return cnt == 4;
}

std::pair <int, int> find_locmin_point(int N, int M) {
    int i, j, n, m;
    n = N;
    m = M;
    i = 1;
    for( j = 0; j <= m + 1; j++ )
        mat[i][j] = LLONG_MAX;
    for( j = 1; j <= m; j++ ) {
        mat[i][j] = value( i, j );
        if( j >= 2 && verif( i, j - 1 ) )
            return { i, j - 1 };
    }
    return { 1, 1 };
}
