Snake And Arena

All submissions for this problem are available.
Tanmay decided to play the Hungry Snake game on his mobile where the snake has to find the food in the shortest time. But he is not finding his mobile anywhere. He comes to you sadly, and as a coder it's your work to design a game for him. $0$ indicate a blank square tile of dimension $1$ X $1$. Each $1$ X $1$ tile takes one second for the snake to pass. $1$ indicate the position of the food. $9$ indicate the position of the snake. Snake can move horizontally or vertically or diagonally. Your task is to find the minimum time taken for the snake to reach it's food. ###INPUT Number of test cases, T. Next line contains two integer, number of rows R and number of columns C in the arena. Each of the next R lines contains C number of inputs. Inputs can be of following types.  $0$ indicate a blank square tile of dimension $1$ X $1$.  $1$ indicate the position of the food (Must be only one entry in each input).  $9$ indicate the position of the snake (Must be only one entry in each input). ###OUTPUT Minimum time required for the snake to reach the food, $T$. ###CONSTRAINTS $R,C \leq 100$ ###NOTE: Entry of $1$ and $9$ for each input is singular, I mean only one such input exists. If answer comes out to be a whole no., then the final output must be the whole no. If answer comes out to be float value, then the final output must be $UPTO$(not precise) $3$ places of decimal. If answer comes out to be 1.28090, then the final output must only be 1.28 I.e zeroes comes out after the digit, you should remove it. For eg. if ans comes out to be 1.2896 then final output will be 1.289. ###Sample Input 2 5 5 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 4 3 0 0 1 0 0 0 0 9 0 0 0 0 ###Sample Output 4.242 2.414Author:  thesuraj007 
Tags  thesuraj007 
Date Added:  13012020 
Time Limit:  0.1  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PHP, GO, NODEJS, rust, SCALA, swift, JS, SQL, kotlin, PYP3, R 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 