#include "locmin.h"
#include <iostream>
#include <climits>
#include <algorithm>
#include <random>
using namespace std;

#define MAXM 500

long long v[MAXM+2];
int ind[MAXM+1];

pair<int,int> find_locmin_point(int N,int M){
  for(int i=1;i<=M;i++){
    ind[i]=i;
  }

  random_device rd;
  mt19937 g(rd());

  shuffle(ind+1,ind+M+1,g);

  v[0]=LLONG_MAX;
  v[M+1]=LLONG_MAX;
  for(int j=1;j<=M;j++){
    int i=ind[j];
    if(v[i]==0){
      v[i]=value(1,i);
    }
    if(i<M&&v[i+1]==0){
      v[i+1]=value(1,i+1);
    }

    if(v[i]<v[i+1]&&v[i]<v[i-1]){
      return {1,i};
    }
  }
}
