You are given a maze. It is a grid with nnn rows and nnn columns. Rows and columns are both numbered from 111 to nnn. The intersection of the aaa-th row and bbb-th column is denoted by (a,b)(a,b). Some cells of the maze are obstacles. Initially, you are standing in the top left corner (1,1)(1,1)(1,1). Your goal is to reach the bottom right corner (n,n)(n,n). You can move in four directions from (a,b)(a,b): up to , down to , left to or right to . You cannot move in the same direction for more than mmm consecutive moves, you cannot leave the grid and the cells with obstacle are unreachable. What is the minimum number of moves to reach (n,n)(n,n)?
You are given a maze. It is a grid with nnn rows and nnn columns. Rows and columns are both numbered from 111 to nnn. The intersection of the aaa-th row and bbb-th column is denoted by (a,b)(a, b)(a,b). Some cells of the maze are obstacles. Initially, you are standing in the top left corner (1,1)(1,1)(1,1). Your goal is to reach the bottom right corner (n,n)(n, n)(n,n). You can move in four directions from (a,b)(a, b)(a,b): up to (a−1,b)(a-1, b)(a−1,b), down to (a+1,b)(a+1, b)(a+1,b), left to (a,b−1)(a, b-1)(a,b−1) or right to (a,b+1)(a, b+1)(a,b+1). You cannot move in the same direction for more than mmm consecutive moves, you cannot leave the grid and the cells with obstacle are unreachable. What is the minimum number of moves to reach (n,n)(n, n)(n,n)?