AT_abc468_b.Corridor Watch
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given integers M,D and a string S of length M consisting of G and ..
There are M cells arranged in a row from left to right, numbered 1 through M from the left.
Some of the cells have a guardman standing on them. Specifically, a guardman stands on cell i if Si= G, and no one stands on cell i if Si= ..
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 Si= G and ∣x−i∣≤D.
Among the M cells, find the number of cells that are not watched.
给你整数 M、D 和一个长度为 M 的字符串 S,其中只包含字符 G 和 .。
从左到右依次排列着 M 个格子,编号从左至右为 1 到 M。
部分格子上站着守卫。具体而言:若 Si= G,则第 i 个格子上站着一名守卫;若 Si= .,则第 i 个格子上无人。
若某个格子与某守卫所在格子的距离不超过 D,则该格子被该守卫监视。即:格子 x 被某守卫监视,当且仅当存在某个格子 i 满足 Si= G 且 ∣x−i∣≤D。
在全部 M 个格子中,求未被监视的格子数量。
输入格式
The input is given from Standard Input in the following format:
M D
S
输入从标准输入以如下格式给出:
M D
S
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
7 1 .G...GG
输出#1
1
输入#2
6 5 ......
输出#2
6
输入#3
21 2 ....G...GG.....G.....
输出#3
6
说明/提示
Sample 1 Explanation:
Only cell 4 is not watched.
Sample 2 Explanation:
All cells are not watched.
Constraints
- 0≤D<M≤100
- D and M are integers.
- Si is a string of length M consisting of
Gand..
样例 1 解释:
只有第 4 个格子未被监视。
样例 2 解释:
所有格子均未被监视。
约束条件
- 0≤D<M≤100
- D 和 M 均为整数。
- Si 是一个长度为 M 的字符串,仅由字符
G和.组成。
输入解题思路,AI测评打分。不知道怎么写?