A973 | Replication--Gold
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
The ill-fated result of watching too many "do it yourself" engineering videos
on the web, Farmer John has accidentally released a self-replicating robot on
his farm!
The farm can be represented by an $N\times N$ grid ($3\le N\le 1000$) where
each grid cell is either empty or filled with rock, and all border squares are
filled with rock. Some non-rock cells are designated as possible starting
locations for the robot.
Farmer John initially places the robot at one of the possible starting
positions. In every hour that follows, all copies of the robot move in one
coordinated mass in the same direction, either north, south, east, or west.
After every $D$ hours ($1 \leq D \leq 10^9$), every copy of the robot
replicates \--- a robot at cell $(x,y)$ that replicates creates new copies in
cells $(x+1,y)$, $(x-1,y)$, $(x,y+1)$, and $(x,y-1)$; the original robot
remains at $(x,y)$. Over time, multiple robots might come to occupy the same
cell.
If moving or replicating would cause any of the robots to move into a rock,
then all robots shut down immediately. Note that this implies that the robots
must eventually shut down, due to the border of the farm being rock.
Help the cows figure out the number of empty squares that could potentially at
some point in time hold a robot.
on the web, Farmer John has accidentally released a self-replicating robot on
his farm!
The farm can be represented by an $N\times N$ grid ($3\le N\le 1000$) where
each grid cell is either empty or filled with rock, and all border squares are
filled with rock. Some non-rock cells are designated as possible starting
locations for the robot.
Farmer John initially places the robot at one of the possible starting
positions. In every hour that follows, all copies of the robot move in one
coordinated mass in the same direction, either north, south, east, or west.
After every $D$ hours ($1 \leq D \leq 10^9$), every copy of the robot
replicates \--- a robot at cell $(x,y)$ that replicates creates new copies in
cells $(x+1,y)$, $(x-1,y)$, $(x,y+1)$, and $(x,y-1)$; the original robot
remains at $(x,y)$. Over time, multiple robots might come to occupy the same
cell.
If moving or replicating would cause any of the robots to move into a rock,
then all robots shut down immediately. Note that this implies that the robots
must eventually shut down, due to the border of the farm being rock.
Help the cows figure out the number of empty squares that could potentially at
some point in time hold a robot.
输入格式
The first line contains two space-separated integers $N$ and $D$. The next $N$
lines of input each contain $N$ characters. Each character is one of '.', 'S',
lines of input each contain $N$ characters. Each character is one of '.', 'S',
An integer counting the number of cells that could at some point in time hold
a robot.
a robot.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted