Manhatan distances

We have a square matrix (A) of integer numbers and a set (S) of integer numbers. For each number (n) in S, the maximum Manhatan distance between two positions of A with the value n is computed. For example, in matrix:
1 3 4 5 3
2 3 2 2 3
5 3 2 5 3
1 1 4 5 2
2 4 3 5 1
given the numbers 2 and 3, the result is 6 and 6 (number 2 in positions 2,1 and 4,5, and number 3 in positions 1,5 and 5,3). If n is not in the matrix or if it is only once, the result is zero.


A number of problems is solved. For each problem the function to parallelize has:

Input parameters:

-int t: the size of the matrix

-int *a: the matrix txt

-int n: the number of integers

-int *numeros: the value of the n integers in the set

Output parameter:

-int *distancias: the maximum distances of the n integers in the matrix

Parallelism parameters:

-int nodo: the number of the MPI process

-int np: the total number of MPI processes