#P5003. 跳舞的线 - 乱拐弯
跳舞的线 - 乱拐弯
Description
A line is on a grid map. It starts at (top-left corner) and must reach . It can only move down or right, and only on integer grid points.
Sometimes Imakf wants to show off, and sometimes he wants to be lazy, so he will give you the entire map. You need to tell him the maximum and minimum number of turns needed to reach the destination.
Input Format
The first line contains two positive integers and .
Lines each contain characters. A # denotes an obstacle; otherwise, the cell is free.
Output Format
Output two positive integers and . is the maximum number of turns, and is the minimum number of turns. If the destination is unreachable, output -1.
5 5
oooo#
ooooo
#oo#o
o#ooo
oo#oo
7 2
5 5
oooo#
ooooo
#oo##
o#o#o
oo#oo
-1
Hint
Explanation for Sample :

The red route has the most turns, and the blue route has the fewest turns.
Explanation for Sample :
Unreachable, so output -1.
Constraints:
| Test points | ||
|---|---|---|
| not specified | ||
| not specified | ||
For of the testdata, it is guaranteed that .
Thanks to @Iowa_BattleShip for pointing out the data error.
Translated by ChatGPT 5
京公网安备 11011102002149号