QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#3680. 序列染色

統計

问题描述

给出一个长度为 $N$ 由 BWX 三种字符组成的字符串 $S$,你需要把每一个 $X$ 染成 BW 中的一个。

对于给出的 $K$,问有多少种染色方式使得存在整数 $a,b,c,d$ 使得:

  • $ 1 \leq a \leq b < c \leq d \leq N$
  • $S_a,S_{a+1},\cdots,S_b$ 均为 B
  • $S_c,S_{c+1}, \cdots ,S_d$ 均为 W

其中 $b=a+K-1$, $d=c+K-1$

由于方法可能很多,因此只需要输出最后的答案对 $10^9+7$ 取模的结果。

输入格式

第一行两个正整数 $N,K$

第二行一个长度为 $N$ 的字符串 $S$

输出格式

一行一个整数表示答案取模 ($10^9+7$)。

样例输入

5 2
XXXXX

样例输出

4

数据约定

对于 $20\%$ 的数据,$N \leq 20$

对于 $50\%$ 的数据,$N \leq 2\,000$

对于 $100\%$ 的数据,$1 \leq N \leq 10^6$,$1 \leq K \leq 10^6$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.