A character moves on an N×N board from the start cell to the target cell. The character starts on (1,1) in normal mode. The target cell is (r,c).
The character is either in normal mode or in transformation mode. In normal mode, one turn moves the character by one cell up, down, left, or right. In transformation mode, one turn moves the character to the nearest warp cell in one of the four directions from the current cell. When the chosen direction holds no warp cell, the character cannot move that way. In transformation mode only warp moves are allowed.
Changing from normal mode to transformation mode takes t turns, and changing back takes no turns. Compute the minimum number of turns needed to reach the target cell from the start cell.