A919 | Push a Box--Platinum
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Bessie and her friends have invented a new game. The game is named accurately,
but not particularly creatively. They call it the "Push A Box Around The Barn
To Get It In The Right Spot And Don't Move The Hay" game (if you think that's
excessive, you should see some of the variable names the cows use when they
write code...)
The barn can be modeled as an $N \times M$ rectangular grid. Some of the grid
cells have hay in them. Bessie occupies one cell in this grid, and a large
wooden box occupies another cell. Bessie and the box are not able to fit in
the same cell at the same time, and neither can fit into a cell containing
hay.
Bessie can move in the 4 orthogonal directions (north, east, south, west) as
long as she does not walk into hay. If she attempts to walk to the space with
the box, then the box will be pushed one space in that direction, as long as
there is an empty cell on the other side. If there is no empty cell, then
Bessie will not be able to make that move.
A certain grid cell is designated as the goal. Bessie's goal is to get the box
into that location.
Given the layout of the barn, including the starting positions of the box and
the cow, and the target position of the box, determine if it possible to win
the game.
Note: This problem allows 512MB of memory usage, up from the default limit of
256MB.
but not particularly creatively. They call it the "Push A Box Around The Barn
To Get It In The Right Spot And Don't Move The Hay" game (if you think that's
excessive, you should see some of the variable names the cows use when they
write code...)
The barn can be modeled as an $N \times M$ rectangular grid. Some of the grid
cells have hay in them. Bessie occupies one cell in this grid, and a large
wooden box occupies another cell. Bessie and the box are not able to fit in
the same cell at the same time, and neither can fit into a cell containing
hay.
Bessie can move in the 4 orthogonal directions (north, east, south, west) as
long as she does not walk into hay. If she attempts to walk to the space with
the box, then the box will be pushed one space in that direction, as long as
there is an empty cell on the other side. If there is no empty cell, then
Bessie will not be able to make that move.
A certain grid cell is designated as the goal. Bessie's goal is to get the box
into that location.
Given the layout of the barn, including the starting positions of the box and
the cow, and the target position of the box, determine if it possible to win
the game.
Note: This problem allows 512MB of memory usage, up from the default limit of
256MB.
输入格式
box's initial location (B).
This is followed by $Q$ lines, each with a pair of integers $(R, C)$. For each
pair, you should determine if it is possible to get the box to that cell at
row $R$, column $C$, starting from the initial state of the barn. The top row
is row 1, and the left column is column 1.
This is followed by $Q$ lines, each with a pair of integers $(R, C)$. For each
pair, you should determine if it is possible to get the box to that cell at
row $R$, column $C$, starting from the initial state of the barn. The top row
is row 1, and the left column is column 1.
输出格式
$Q$ lines, each with either the string "YES" or "NO".
输入输出样例
输入 #1
5 5 4 ##.## ##.## A.B.. ##.## ##.## 3 2 3 5 1 3 5 3
输出 #1
NO YES NO NO
The first line has three numbers, $N$, $M$, and $Q$, where $N$ is the number
of rows in the grid and $M$ is the number of columns.
* $1 \le N,M \le 1500$.
* $1 \le Q \le 50,000$.
On the next $N$ lines is a representation of the grid, where characters
of rows in the grid and $M$ is the number of columns.
* $1 \le N,M \le 1500$.
* $1 \le Q \le 50,000$.
On the next $N$ lines is a representation of the grid, where characters
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted