A11550 | New Year and Buggy Bot
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Bob programmed a robot to navigate through a 2d maze.
The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '\#'.
There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a single exit in the maze. Its position is denoted with the character 'E'. This position has no obstacle in it.
The robot can only move up, left, right, or down.
When Bob programmed the robot, he wrote down a string of digits consisting of the digits 0 to 3, inclusive. He intended for each digit to correspond to a distinct direction, and the robot would follow the directions in order to reach the exit. Unfortunately, he forgot to actually assign the directions to digits.
The robot will choose some random mapping of digits to distinct directions. The robot will map distinct digits to distinct directions. The robot will then follow the instructions according to the given string in order and chosen mapping. If an instruction would lead the robot to go off the edge of the maze or hit an obstacle, the robot will crash and break down. If the robot reaches the exit at any point, then the robot will stop following any further instructions.
Bob is having trouble debugging his robot, so he would like to determine the number of mappings of digits to directions that would lead the robot to the exit.
The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '\#'.
There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a single exit in the maze. Its position is denoted with the character 'E'. This position has no obstacle in it.
The robot can only move up, left, right, or down.
When Bob programmed the robot, he wrote down a string of digits consisting of the digits 0 to 3, inclusive. He intended for each digit to correspond to a distinct direction, and the robot would follow the directions in order to reach the exit. Unfortunately, he forgot to actually assign the directions to digits.
The robot will choose some random mapping of digits to distinct directions. The robot will map distinct digits to distinct directions. The robot will then follow the instructions according to the given string in order and chosen mapping. If an instruction would lead the robot to go off the edge of the maze or hit an obstacle, the robot will crash and break down. If the robot reaches the exit at any point, then the robot will stop following any further instructions.
Bob is having trouble debugging his robot, so he would like to determine the number of mappings of digits to directions that would lead the robot to the exit.
输入格式
The first line of input will contain two integers $n$ and $m$ ( $2<=n,m<=50$ ), denoting the dimensions of the maze.
The next $n$ lines will contain exactly $m$ characters each, denoting the maze.
Each character of the maze will be '.', '\#', 'S', or 'E'.
There will be exactly one 'S' and exactly one 'E' in the maze.
The last line will contain a single string $s$ ( $1<=|s|<=100$ ) — the instructions given to the robot. Each character of $s$ is a digit from 0 to 3.
The next $n$ lines will contain exactly $m$ characters each, denoting the maze.
Each character of the maze will be '.', '\#', 'S', or 'E'.
There will be exactly one 'S' and exactly one 'E' in the maze.
The last line will contain a single string $s$ ( $1<=|s|<=100$ ) — the instructions given to the robot. Each character of $s$ is a digit from 0 to 3.
输出格式
Print a single integer, the number of mappings of digits to directions that will lead the robot to the exit.
输入输出样例
输入 #1
5 6 .....# S....# .#.... .#.... ...E.. 333300012
输出 #1
1
输入 #2
6 6 ...... ...... ..SE.. ...... ...... ...... 01232123212302123021
输出 #2
14
输入 #3
5 3 ... .S. ### .E. ... 3
输出 #3
0
For the first sample, the only valid mapping is , where $D$ is down, $L$ is left, $U$ is up, $R$ is right.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted