Question
The suzan and rose of the students in the first level in the course of programming methods they learned a kind of drawing square shapes
The suzan and rose of the students in the first level in the course of programming methods they learned a kind of drawing square shapes using matrices, and since they like playing always suggested suzan on rose of a game, where the suzan gives rose square matrix with a diameter of N, all of its elements 0 except one component equal to 1, then rose is finding the fewest possible steps to move the 1 to the center of the array. help rose solve this problem. For example, the diameter of the matrix = 5 if the matrix will be 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 solution: in this example number 1 needs 3 steps to reach the center one step up and two steps To the left so the matrix becomes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 and the result is 3
Input Format
N = the size of the square matrix arr = the shape of the zero matrix
Constraints
100> N> 0
Output Format
P = the fewest steps to reach the position
Sample Input 0
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Sample Output 0
3
P = the fewest steps to reach the position
using c++ or python3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started