P1825 [USACO11OPEN] Corn Maze S

题目描述

This past fall, Farmer John took the cows to visit a corn maze. But this wasn't just any corn maze: it featured several gravity-powered teleporter slides, which cause cows to teleport instantly from one point in the maze to another. The slides work in both directions: a cow can slide from the slide's start to the end instantly, or from the end to the start. If a cow steps on a space that hosts either end of a slide, she must use the slide. The outside of the corn maze is entirely corn except for a single exit. The maze can be represented by an N x M (2

输入格式

输出格式

说明/提示

例如以下矩阵,$N=5,M=6$。 ```plain ###=## #.W.## #.#### #.@W## ###### ``` 唯一的一个装置的结点用大写字母 $\tt{W}$ 表示。 最优方案为:先向右走到装置的结点,花费一个单位时间,再到装置的另一个结点上,花费 $0$ 个单位时间,然后再向右走一个,再向上走一个,到达出口处,总共花费了 $3$ 个单位时间。