当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2170:Frogger

题目描述
Philip J. Frog just wanted to go for a mid-afternoon swim, but in typical frog fashion he's ended up in the middle of a busy street. Help Phil figure out how long he'll be hopping on hot asphalt before he finds his way to the nice cool water.

Phil may hop one square horizontally or vertically per second. He may only hop onto road, grass, or water. Additionally, he cannot occupy any square occupied by a car. Phil and the cars move at the same time, meaning Phil can “hop over” an oncoming car. Phil can also remain in the same square if he wishes. All horizontal movement wraps (e.g., a rightward hop from the rightmost column places Phil in the leftmost column). Cars move horizontally in the direction indicated on the map ('<' means leftward, '>' means rightward) at a rate of one square per second and never collide with anything.

输入解释
Input begins with a single integer specifying the number of test maps. Each map begins with two integers R and C (0 < R, C <= 30) specifying the number of rows and columns, respectively, followed by R lines each C characters long, specifying the map. The possible map characters are:

Phil ('&') - Phil's starting location. Each map contains exactly one. Always indicates road underneath.
Tree ('T') - Impassable.
Grass ('.') - Phil can move freely in the grass.
Road ('-') - Hot!
Car ('<', '>') - Always indicates road underneath.
Water ('~') - Phil's goal.
输出解释
For each map, output a line containing the fewest number of seconds Phil must spend on the road in order to reach the water, or the string “Impassable”, if no path to water exists.

输入样例
3
2 1
~
&
4 7
~TTTTTT
.------
-->-<--
---&---
3 5
~~~~~
..T..
>>&<<
输出样例
1
6
Impassable
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2170

最后修改于 2020-10-25T22:51:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1000MS(Java/Others) 65536/32768K(Java/Others)