/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
整数 M,D と、 G, . からなる長さ M の文字列 S が与えられます。
M 個のマスが左右に一列に並んでおり、左から順にそれぞれ 1 から M までの番号がついています。
いくつかのマスにはガードマンが立っています。具体的には、S_i= G ならばマス i にはガードマンが立っており、S_i= . ならばマス i には誰も立っていません。
ガードマンが立っているマスからの距離が D 以下であるマスはガードマンによって監視されます。すなわち、あるマス i が存在して S_i= G かつ |x-i|\le D を満たすマス x はガードマンによって監視されます。
M 個のマスのうち、監視されていないマスの個数を求めてください。
制約
- 0\le D < M \le 100
- D,M は整数
- S_i は
Gと.からなる長さ M の文字列
入力
入力は以下の形式で標準入力から与えられる。
M D S
出力
答えを出力せよ。
入力例 1
7 1 .G...GG
出力例 1
1
マス 4 のみが監視されていません。
入力例 2
6 5 ......
出力例 2
6
全てのマスが監視されていません。
入力例 3
21 2 ....G...GG.....G.....
出力例 3
6
Score : 200 points
Problem Statement
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 S_i= G, and no one stands on cell i if S_i= ..
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.
Among the M cells, find the number of cells that are not watched.
Constraints
- 0\le D < M \le 100
- D and M are integers.
- S_i is a string of length M consisting of
Gand..
Input
The input is given from Standard Input in the following format:
M D S
Output
Output the answer.
Sample Input 1
7 1 .G...GG
Sample Output 1
1
Only cell 4 is not watched.
Sample Input 2
6 5 ......
Sample Output 2
6
All cells are not watched.
Sample Input 3
21 2 ....G...GG.....G.....
Sample Output 3
6