走廊监视AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given integers $M,D$ and a string $S$ of length $M$ consisting of G and ..
给定整数 $M,D$ 和一个长度为 $M$、由 G 和 . 组成的字符串 $S$。AI (CI翻译)
There are $M$ cells arranged in a row from left to right, numbered $1$ through $M$ from the left.
有 $M$ 个格子从左到右排成一行,从左边起依次编号为 $1$ 到 $M$。AI (CI翻译)
Some of the cells have a guardman standing on them. Specifically, a guardman stands on cell $i$ if $S_i=$ G, and no one stands on cell $i$ if $S_i=$ ..
部分格子上站着警卫。具体来说,若 $S_i=$ G,则格子 $i$ 上站着一名警卫;若 $S_i=$ .,则格子 $i$ 上没有人。AI (CI翻译)
A cell whose distance from a cell with a guardman is at most $D$ is watched by that guardman. That is, a cell $x$ is watched by a guardman if there exists a cell $i$ such that $S_i=$ G and $|x-i|\le D$.
与某个有警卫的格子距离不超过 $D$ 的格子会被该警卫监视。也就是说,存在一个格子 $i$ 满足 $S_i=$ G 且 $|x-i|\le D$ 时,格子 $x$ 会被警卫监视。AI (CI翻译)
Among the $M$ cells, find the number of cells that are not watched.
请在这 $M$ 个格子中,求出没有被监视的格子数。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$0\le D < M \le 100$$D$and$M$are integers.$S_i$is a string of length$M$consisting ofGand..
$0\le D < M \le 100$$D$和$M$均为整数。$S_i$是一个长度为$M$、由G和.组成的字符串。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
M D
S
M D
SAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the answer.
输出答案。AI (CI翻译)
样例
7 1
.G...GG
1
6 5
......
6
21 2
....G...GG.....G.....
6
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。