#include "locmin.h"
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
using ll = long long;

const int MAX_M = 500;
ll a[MAX_M + 1];

ll get(int i) {
    if(a[i] == 0) {
        return a[i] = value(1, i);
    } else {
        return a[i];
    }
}

std::pair<int, int> find_locmin_point(int n, int m) {
    srand(time(0));
    int b = 100;
    std::vector<int> v;
    for(int i = 0; i < b; i++) {
        v.push_back(1 + rand() % m);
    }
    std::sort(v.begin(), v.end());
    std::vector<int> nv;
    nv.push_back(v[0]);
    for(int i = 1; i < int(v.size()); i++) {
        if(v[i] != v[i - 1]) {
            nv.push_back(v[i]);
        }
    }
    v = nv;
    int sz = int(v.size());
    for(int i = 1; i < sz - 1; i++) {
        if(get(v[i - 1]) > get(v[i]) && get(v[i]) < get(v[i + 1])) {
            return {1, v[i]};
        }
    }
    return {1, 1};
}
