There is a 5∗5 matrix. There are four kinds of colors in the matrix: white(W), yellow(Y), purple(P), and black(B), and there is only one white element. Assume the white element is at (i, j). In each operation, it can swap the position with other element on (i',j'), if(|i-i'|,|j-j'|) ∈ {(1,2),(2,1)}.
The question need to calculate the minimum operations need to be performed to change the matrix to another given matrix.
ex. Below is an example, the first five lines denotes the given matrix, another five lines denotes the matrix that need to turn into. For the below example, the answer of the minimum operation is 2. Any hints on how to solve this?
BYBBB
BBBPB
BBWBB
BBBBB
BBBBB
BPBBB
BBBWB
BBYBB
BBBBB
BBBBB
Aucun commentaire:
Enregistrer un commentaire