CF204D.Little Elephant and Retro Strings

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Little Elephant has found a ragged old black-and-white string ss on the attic.

The characters of string ss are numbered from the left to the right from 11 to s|s| , where s|s| is the length of the string. Let's denote the ii -th character of string ss as sis_{i} . As the string is black-and-white, each character of the string is either letter "B", or letter "W". Unfortunately, the string is very old and some characters are damaged. The damaged positions are denoted as "X".

The Little Elephant in determined to restore the string and hang it on the wall. For that he needs to replace each character "X" by a "B" or a "W". The string must look good on the wall, so it must be beautiful. The Little Elephant considers a string beautiful if it has two non-intersecting substrings of a given length kk , such that the left one fully consists of characters "B", and the right one fully consists of characters "W". More formally, there are four integers a,b,c,da,b,c,d (1<=a<=b<c<=d<=s; ba+1=dc+1=k)(1<=a<=b<c<=d<=|s|; b-a+1=d-c+1=k) such that sis_{i} = "B" (a<=i<=b)(a<=i<=b) and sjs_{j} = "W" (c<=j<=d)(c<=j<=d) .

Help the Little Elephant find the number of different beautiful strings he can obtain from string ss . Two strings are considered different if there is such position, where the character in the first string differs from the corresponding character in the second string. If this string doesn't contain characters «X» and it is already beautiful — the answer is 1.

As the answer can be rather large, print it modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入格式

The first line contains two space-separated integers nn and kk (1<=k<=n<=106)(1<=k<=n<=10^{6}) . The second line contains string ss . String ss has length nn and only consists of characters "W", "B" and "X".

输出格式

On a single line print an integer — the answer to the problem modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入输出样例

  • 输入#1

    3 2
    XXX
    

    输出#1

    0
    
  • 输入#2

    4 2
    XXXX
    

    输出#2

    1
    
  • 输入#3

    10 2
    XXBXXWXXXX
    

    输出#3

    166
    
首页