AtCoder Beginner Contest 468
B
走廊监视
Corridor Watch
AtCoder
⌀ 0
原题
←C →

走廊监视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 of G and ..
  • $0\le D < M \le 100$
  • $D$ 和 $M$ 均为整数。
  • $S_i$ 是一个长度为 $M$、由 G 和 . 组成的字符串。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

M D
S

M D
S
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the answer.

输出答案。AI (CI翻译)

样例

Input #1
7 1
.G...GG
Output #1
1
Only cell $4$ is not watched.
Input #2
6 5
......
Output #2
6
All cells are not watched.
Input #3
21 2
....G...GG.....G.....
Output #3
6
题目信息
题号
abc468_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。